I am using NPOI 2.1.3.1 to write out a workbook but I got a blank header after write to file.
Detailed operation is:
Load an existing xlsx file into memory
Workbook = WorkbookFactory.Create(stream);
I took the first row/header to lookup some values, but don't change anything on it.
var firstRow = sheet.GetRow(sheet.FirstRowNum);
var columns = GetColumns(firstRow);
// Set other cells, but didn't touch the header...
Removed the 2nd row and create a new row as the 2nd row.
sheet.RemoveRow(row);
sheet.CreateRow(1);
Save the workbook to another file using Write
method.
The problem is the saved file is missing the header values.
And when I debug into the code and check the workbook after the Write
The header cells were still there. What happened for Write
method?
This is confirmed as a bug for NPOI.
ISheet.RemoveRow
has removed wrong row from underlying data list.
I've submited pull request and hopefully can be resolved in next release of NPOI.