This project has moved. For the latest updates, please go here.

Loading SSRS Excel spreadsheet throws Object reference not set error

Nov 20, 2014 at 3:57 PM
Edited Nov 20, 2014 at 4:13 PM
I'm loading the xlsx excel spreadsheet that was created from a SSRS report built using Sql Server Data Tools of Sql Server 2012. Has this happened to anyone else?

In this line:
XLWorkbook workbook = new XLWorkbook("TestReport.xlsx");

I get the following error.
System.NullReferenceException: Object reference not set to an instance of an object.
at ClosedXML.Excel.XLWorkbook.LoadCells(SharedStringItem[] sharedStrings, Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, Dictionary2 sharedFormulasR1C1, XLWorksheet ws, Dictionary2 styleList, Cell cell, Int32 rowIndex)
at ClosedXML.Excel.XLWorkbook.LoadRows(Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, XLWorksheet ws, SharedStringItem[] sharedStrings, Dictionary2 sharedFormulasR1C1, Dictionary2 styleList, Row row)
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
at ClosedXML.Excel.XLWorkbook.Load(String file)
at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking)
at ClosedXML.Excel.XLWorkbook..ctor(String file)
Jan 16, 2015 at 3:30 AM
Edited Jan 16, 2015 at 4:08 AM
I have the same problem .
"Object reference not set to an instance of an object."
I didn't have this problem when we called XLWorkbook on a SSRS 2008 Excel file (rendered to EXCEL via Reportservice ) but now i got the problem when we upgraded SQL 2014. (rendered to EXCELOPENXML)
Feb 11, 2015 at 11:28 AM
Edited Feb 11, 2015 at 11:30 AM
Same here using EXCELOPENXML.

It looks like SSRS is putting invalid characts into the XML. It may be related to this EPPlus thread:

Haven't found a way around yet.

Remember: EXCELOPENXML produces a openXML documents instead of EXCELs old binary format. XLS != XLSX