I'd like to set the first row on my sheet to Bold. Sounds
, but when I set row.RowStyle it's not applied to the cells I add to that row. i.e. I open the resulting workbook and the font is not bold. BUT the font of later cells in the row ARE bold, i.e. if I type in Excel into blank cells in the
row to the right of ones created in code they are formatted in bold. What's going on here, am I creating the cells incorrectly or do they just not inherit the formatting of the row?
var workbook = new XSSFWorkbook();
var sheet = workbook.CreateSheet("Requests");
IDataFormat format = workbook.CreateDataFormat();
// Write header row
var rowNum = 0;
var row = sheet.CreateRow(rowNum++);
var col = 0;
var rowstyle = workbook.CreateCellStyle();
var boldFont = workbook.CreateFont();
boldFont.Boldweight = (short)FontBoldWeight.Bold;
row.RowStyle = rowstyle;
I see various other questions about this on stackoverflow (here
) but no answers other than applying the same style to each cell. Doesn't that almost defeat the purpose of having RowStyle?