Free Support Forum - aspose.com

Workbook.LoadData() is not loading xlsx file

Workbook wb = new Workbook();

wb.LoadData(Excelfile);

Unable to load excel file (.xlsx) and successfully loading (.xls) file.

Using 7.4.0.0 Aspose.cells.

Help me out.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We do not have any such API. I think, you have mistaken something. Please provide us your sample runnable project replicating this issue with the latest version: Aspose.Cells for .NET 7.4.1.

Please also provide the source input and output files.

We will check your issue and help you asap.

Hi,


Well, I think you might be using an older version which had this API (LoadData method), which is now obsoleted in the new versions of the product. As suggested by Shakeel Faiz, please use latest version/fix v7.4.1.x and see the following sample code for your reference. In the code you will on how to load only data while opening the file.

//Instantiate LoadOptions specified by the LoadFormat
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
//Set the LoadDataOption
LoadDataOption dataOption = new LoadDataOption();
dataOption.ImportFormula = true;
//Only data should be loaded.
loadOptions.LoadDataOnly = true;
//Specify the LoadDataOption
loadOptions.LoadDataOptions = dataOption;

//Create a Workbook object and opening the file from the stream
Workbook wb = new Workbook(“e:\test\Book1.xlsx”, loadOptions);


Also, we recommend you to kindly see the documents for your complete reference on how you will open/read Excel files.
http://www.aspose.com/docs/display/cellsnet/Opening+Files


Moreover, as you might be getting issue in your older version for LoadData method, I am afraid, we cannot help much and also cannot fix any issue in the older versions of the product. We can only recommend the clients to upgrade and use latest versions of the product which is more reliable and has feature rich APIs. Also, if you find any issue using latest version of the product, we are bound to fix the issue and provide you the fix here.

Thank you.

We tried as you suggested, but still getting an error.

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

More over we need to load xls and xlsx files. Not only .Xlsx

Following is the code snippet :

LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);

//Set the LoadDataOption

LoadDataOption dataOption = new LoadDataOption();

dataOption.ImportFormula = true;

//Only data should be loaded.

loadOptions.LoadDataOnly = true;

//Specify the LoadDataOption

loadOptions.LoadDataOptions = dataOption;

//Create a Workbook object and opening the file from the stream

Workbook wb = new Workbook(Excelfile, loadOptions);

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Your code is correct and does not have any problem.

It seems, there is some problem with your excel file. Please post your excel file. We will check your issue soon.

Here is the excel that we are trying to load.

Hi,


Please try the attached latest version/fix:Aspose.Cells for .NET v7.4.1.2.

I have tested using your attached file and it works absolutely fine. Here is the sample code with your file.

Sample code:

//Instantiate LoadOptions specified by the LoadFormat
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
//Set the LoadDataOption
LoadDataOption dataOption = new LoadDataOption();
dataOption.ImportFormula = true;
//Only data should be loaded.
loadOptions.LoadDataOnly = true;
//Specify the LoadDataOption
loadOptions.LoadDataOptions = dataOption;

//Create a Workbook object and opening the file from the stream
Workbook wb = new Workbook(@“e:\test2\Test+inputsheet+for+OPS+programma+tool.xlsx”, loadOptions);


Please try our latest fix/version v7.4.1.2.

Thank you.

Hi.

We are facing same issue..

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

Stack Trace :

at ڍ.↗.ↇ(XmlTextReader ొ)
at ڍ.↗.↞(XmlTextReader ೡ)
at ڍ.䐴.⅊()
at ڍ.䐴.ࡏ()
at ڍ.䐴.䐵(Workbook ಷ, Stream Ԡ, LoadDataOption ܘ)
at Aspose.Cells.Workbook.ԝ(Stream Ԡ, LoadOptions ԟ)
at Aspose.Cells.Workbook.ԝ(String Ԟ, LoadOptions ԟ)
at Aspose.Cells.Workbook..ctor(String file, LoadOptions loadOptions)
at BusinessLogic.ExcelCommunication.FillDocumentFromExcel(Document document, String Excelfile, List`1& Errors) in I:\OPT Avinash\SourceCode\PUPM\2.BusinessLayer\BusinessLogic\ExcelCommunication.cs:line 60

Please look into this.

Hi,


As I requested you to kindly try our latest fix/version: v7.4.1.2: Workbook.LoadData() is not loading xlsx file

If you still find the issue, let us know.

For your information, if you still using your older version, I am afraid, we cannot help you much. Neither we can resolve the issue if it exists in the older versions. We can only evaluate and fix the issues in the latest versions of the product.


Thanks for your understanding!

We are using latest version v7.4.1.2...

Hi,


I am using the following code with your template file you attached earlier.

Sample code:

//Instantiate LoadOptions specified by the LoadFormat
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
//Set the LoadDataOption
LoadDataOption dataOption = new LoadDataOption();
dataOption.ImportFormula = true;
//Only data should be loaded.
loadOptions.LoadDataOnly = true;
//Specify the LoadDataOption
loadOptions.LoadDataOptions = dataOption;

//Create a Workbook object and opening the file from the stream
Workbook wb = new Workbook(@“e:\test2\Test+inputsheet+for+OPS+programma+tool.xlsx”, loadOptions);


If you are using some other template file, please attach it here. We will check it soon.

If you are using the same file, please create a separate console application with v7.4.1.2, zip the project and attach it here, we will check it soon.

Thank you.