I'm creating an excel xlsx file from scratch with NPOI in c#, and need to have specific cellstyles for each of my cells. But as far as i can tell, every time i change the cellstyle of one of my cells, it modifies another unrelated cell.
Each time I create a cell, i assign a Cellstyle created right before with my XSSFWorkbook.CreateCellStyle(). I assume it should be a particular cellstyle just for the cell. However i see that it's not true and it seems to be the same reference as cells created before or after. Despite me calling XSSFWorkbook.CreateCellStyle() and setting it for each cell i'm creating.
Here's how I create my cells :
for (var i = 0; i < nbCellules; i++)
{
var cell = row.CreateCell(i);
var style = xssfwb.CreateCellStyle();
cell.CellStyle = xssfwb.CreateCellStyle();
cell.CellStyle.BorderLeft = GetLeftBorderStyleFromIndex(i);
cell.CellStyle.BorderRight = GetRightBorderStyleFromIndex(i);
}
With that code, I do the following :
row.GetCell(0).CellStyle.BorderBottom = BorderStyle.Thick;
I think that only that particular cell should be impacted.
However, every row now has a thick bottom border aswell.
Does somebody knows where I'm wrong?