We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullReferenceException... Object reference not set to an instance of an object

Hi, just recently we have been getting an "object reference not set to an instance of an object" error using aspose.cells version 4.8.0.0 while trying to use ExportDataTable with an uploaded .xls file. The upload was working fine until this week.

Here's the code used...

myStream = fuUpload.FileContent
Dim workbook As New Workbook
workbook.Open(myStream, FileFormatType.Excel2003)

Dim shtHeader As Worksheet = workbook.Worksheets("Header")
Dim dtHeader As New DataTable
dtHeader = shtHeader.Cells.ExportDataTable(0, 0, shtHeader.Cells.MaxDataRow + 1, shtHeader.Cells.MaxDataColumn + 1, True)

I have tried different versions of the .dll and the results have been the same. Any idea what could be causing this? I've attached an example of the file being uploaded.

Hi,

I have tested your code and template file with the attached latest version/fix and it works fine.

Please try it.

Thank you.

Thanks for your quick response. I think we've found the issue on our end in another file. The culprit ended up being a blank column inserted between columns of data. This hadn't appeared to be a problem until recently. Is it possible one of the recent MS Excel patches could've caused this to be an isssue? Previously Aspose.Cells ignored the blank columns and proceeded to the next... or am I just imagining that?

Thanks again!

Hi,

Well, it will throw exception if a column has very first record empty. We have to check the first row data to get/determine the column type whether it is string or number. Please try your case with my attached version, if you find any issue, kindly do post your template file, we will check your issue soon.

Thank you.