I get a “Object reference not set to an instance of an object” message when I try to load an xlsx file into a new workbook object. I am attaching the file. I am using Aspose.Cells.dll version 7.3.1.0
Hi,
Thanks for using Aspose.Cells for .NET.
Please download and use the latest version: Aspose.Cells for .NET (Download Section)
It should work fine. Let us know your feedback.
I have loaded your file with this version and it did not give any error while loading.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\Import+Form+from+File.xlsx”;
Workbook workbook =
new Workbook(filePath);
It still didn’t work for me. My code:
TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.Xlsx);
loadOptions.ConvertDateTimeData = false;
Workbook importData = new Workbook(file.InputStream, loadOptions);
file.Input was passed from the client side on a post. I’m still getting the same exception with 7.3.1.3
Hi,
I have checked your code segment you shared. Well, you are trying to extract something from nothing which is not possible, you are using TxtLoadOptions with XLSX (Excel 2007/2010) format to try to load it. Also, the property ConvertDateTimeData is only for TxtLoadOptions --> it only refers to txt, CSV, Tab Delimited file formats. So, you cannot use this property for XLSX file format.
Please see the updated code segment:
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
Workbook importData = new Workbook(file.InputStream, loadOptions);
I have checked it and it works fine.
Thank you.
Yes changing txtLoadOptions to LoadOptions worked. Thank you.
Hi,
Good to know that your issue is resolved now.
We recommend you to kindly see the topic for your complete reference on loading different Excel files with different options:
Thank you.