This issue persists in my current setup. I am utilizing version 2.4.1 of the NuGet NPOI package, which includes a bugfix for the FontHeight property but has also introduced this new problem.
The main issue is that the font size returned by xssfWorkbook.createFont() is excessively small. To address this, you need to explicitly set it as follows:
IFont font = excel.CreateFont();
font.FontHeightInPoints = 11;
I have encountered similar errors when working with files that were previously repaired. It is important to ensure that you write to a new file each time you modify your code to avoid any lingering corruptions from affecting your work.
Here is a complete example showcasing how to handle header cell styles:
/// <summary>
/// Return style for header cells.
/// </summary>
/// <returns></returns>
private static ICellStyle GetHeaderStyle(this XSSFWorkbook excel)
{
IFont font = excel.CreateFont();
font.IsBold = true;
//Manually setting font size to address initial tiny font
font.FontHeightInPoints = 11;
ICellStyle style = excel.CreateCellStyle();
style.FillForegroundColor = IndexedColors.Grey25Percent.Index;
style.FillPattern = FillPattern.SolidForeground;
style.FillBackgroundColor = IndexedColors.Grey25Percent.Index;
style.BorderBottom = style.BorderLeft = style.BorderRight = style.BorderTop = BorderStyle.Thin;
style.BottomBorderColor = style.LeftBorderColor = style.RightBorderColor = style.TopBorderColor = IndexedColors.Black.Index;
style.SetFont(font);
return style;
}