Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two identical results for FillPattern #1188

Closed
KBA696 opened this issue Sep 19, 2023 · 3 comments
Closed

Two identical results for FillPattern #1188

KBA696 opened this issue Sep 19, 2023 · 3 comments

Comments

@KBA696
Copy link

KBA696 commented Sep 19, 2023

NPOI 2.6.2
XL (.xlsx)

var cellStyle8 = (XSSFCellStyle)workbook.CreateCellStyle();
cellStyle8.FillPattern = FillPattern.AltBars
or
cellStyle8.FillPattern = FillPattern.LessDots

https://skrinshoter.ru/sLt6gZWNK5p?a

missing https://skrinshoter.ru/sLtQEXWgEjf?a

@KBA696 KBA696 added the bug label Sep 19, 2023
@tonyqus tonyqus added this to the NPOI 2.7.1 milestone Sep 19, 2023
@Bykiev
Copy link
Collaborator

Bykiev commented Oct 2, 2023

@KBA696, hi!
I've researched the issue and didn't find any issues with the fill pattern. It seems you didn't specify fill foreground color. Check this code:

using (var book = new XSSFWorkbook())
{
    var sheet = book.CreateSheet("Sheet1");
    var row = sheet.CreateRow(0);

    var cell = row.CreateCell(0);
    var style = book.CreateCellStyle();
    style.FillPattern = FillPattern.AltBars;
    style.FillForegroundColor = IndexedColors.Black.Index;
    cell.CellStyle = style;

    var cell2 = row.CreateCell(1);
    var style2 = book.CreateCellStyle();
    style2.FillPattern = FillPattern.LessDots;
    style2.FillForegroundColor = IndexedColors.Black.Index;
    cell2.CellStyle = style2;

    using (var ms = new MemoryStream())
    {
        book.Write(ms);
        File.WriteAllBytes("test.xlsx", ms.ToArray());
    }
}

@KBA696
Copy link
Author

KBA696 commented Oct 2, 2023

I double-checked on a clean project and everything works.
it was necessary to record a video((
The screenshots were with this code:
using (var book = new XSSFWorkbook())
{
var sheet = book.CreateSheet("Sheet1");
var row = sheet.CreateRow(0);

for (int i = 0; i <= 18; i++)
{
    var cell = row.CreateCell(i);
    var style = book.CreateCellStyle();
    style.FillPattern = (FillPattern)i;
    cell.CellStyle = style;
}

using (var ms = new MemoryStream())
{
    book.Write(ms);
    System.IO.File.WriteAllBytes("test.xlsx", ms.ToArray());
}

}

@KBA696 KBA696 closed this as completed Oct 2, 2023
@KBA696
Copy link
Author

KBA696 commented Oct 2, 2023

@Bykiev Спасибо большое да проблема была именно в style2.FillForegroundColor = IndexedColors.Black.Index;
с этой записью все заливки работают, а без AltBars и LessDots становятся одинаковыми

@Bykiev Thank you very much yes the problem was exactly in style2.FillForegroundColor = IndexedColors.Black.Index;
with this entry, all fills work, but without AltBars and LessDots become the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants