I have some code that I’m using to try to use ImportCustomObjects. But for some reason no matter what I do I cannot set the colors of the header row. I’m able to manipulate the formatting but the colors are not being set. And the formulas are not executing at the end.
sheet.Cells.ImportCustomObjects(list: collections, propertyNames: header.ToArray(), isPropertyNameShown: true,
firstRow: 0, firstColumn: 0, rowNumber: collections.Count, insertRows: true, dateFormatString: dateFormat,
convertStringToNumber: false);
for (int i = 0; i < headers.Count; i++)
{
var flag = new StyleFlag();
flag.CellShading = true;
var style = sheet.Cells[0, i].GetStyle();
style.BackgroundColor = Color.Orange;
sheet.Cells[0, i].SetStyle(style, flag);
}
wb.Worksheets[0].AutoFitColumns();
wb.CalculateFormula(new CalculationOptions { Recursive = true });
wb.Save(fileName: filename, saveFormat: SaveFormat.Xlsx);