Dec 7, 2011 at 8:58 PM
Edited Dec 8, 2011 at 5:29 AM
'myWorkbook.Workbook.Size' threw an exception of type 'System.NullReferenceException'
When I open an .xls file containing one sheet, and modify that single sheet, and then FileStream the workbook to the filesystem, it works.
When I open an .xls with a handful of sheets (e.g. 5 sheets) the code properly iterates through the sheets and does modfications on each sheet.
In both cases, 'myWorkbook.Workbook.Size' threw an exception of type 'System.NullReferenceException'
The workbook with one sheet writes OK
even with exception: 'myWorkbook.Workbook.Size' threw an exception of type 'System.NullReferenceException'
The workbook with more than one sheet
does not write to FileSystem OK: 0KB / Corrupt
FileStream fsRead =
HSSFWorkbook myWorkbook =
int numSheets = myWorkbook.NumberOfSheets;
sheetNum = 0; sheetNum < numSheets; sheetNum++)
ISheet sheet = myWorkbook.GetSheetAt(sheetNum);
rowNum=0; rowNum<sheet.LastRowNum; rowNum++)
IRow dataRow = sheet.GetRow(rowNum);
cell in dataRow)
FileStream fsWrite =