1
Vote

FillForegroundColor is slow

description

I have a template and after filling it with values I set a background color but for a small file (about 6000 rows) it takes about 4 minutes. Without setting background color it takes only 8 seconds.

My code is:
var hssfworkbook = new XSSFWorkbook(file);
var sheet = hssfworkbook.GetSheetAt(0);

for (int i=0; i<sheet.LastRowNum; i++)
{
var currentCellStyle = hssfworkbook.CreateCellStyle();
currentCellStyle.FillForegroundColor = IndexedColors.Green.Index;
currentCellStyle.FillPattern = FillPattern.SolidForeground;
currentRow.Cells.ForEach(x=> x.CellStyle = currentCellStyle);
}

comments