Monday 16 April 2012

Excel 2010 unable to open file created by ExcelLibrary

This post documents a workaround for a bug in ExcelLibrary. If you create a file of size less than 7KB, Excel 2010 is unable to open the file. To solve this, prepopulate the worksheet with at least 200 rows containing empty cells.

for (int rowIndex = 0; rowIndex < 200; rowIndex++)
{
    sheet.Cells[rowIndex, 0] = new Cell(string.Empty);
}