Error opening ODS file

Hello,

I have put together different formats / formulas etc. for testing Cells. I saved the file with Excel in *.ods. Unfortunately, a formula or whatever seems to prevent the opening of the file using Cells.

Code / File (17.3 KB)

Workbook book = new Workbook("ErrorOpening.ods"); //Cells Version 18.2.0

Exception

: ReadElementString only could be called when the content is simple or empty.

@mservdev,

Thanks for the template file and sample code.

Please try our latest version/fix: e.g Aspose.Cells for .NET v18.2.2:

I have tested your scenario/case using your template file and sample code with v18.2.2 and it works fine and I don’t find any exception/issue.

@Amjad_Sahi

Sorry but I got the same exception with my sample file. I have seen in another post that there is version 18.2.4, I will test it right away. Also the Exception type seems encrypted: An unhandled exception of type ’ ’ occurred in Aspose.Cells.dll

Exception

was unhandled
HResult=-2146232832
Message=ReadElementString only could be called when the content is simple or empty.
Source=Aspose.Cells
StackTrace:
bei ​ . ()
bei . (Cell , Font , Int32 , Int32 )
bei . (Cell , ArrayList , Int32 , Int32 )
bei . (Int32 , Int32 , Boolean )
bei . ()
bei . ( ​ , )
bei . ()
bei . ()
bei . ( )
bei . (Boolean )
bei . ( )
bei . (Stream )
bei Aspose.Cells.Workbook. (Stream , LoadOptions , Boolean )
bei Aspose.Cells.Workbook. (String , LoadOptions )
bei Aspose.Cells.Workbook…ctor(String file)

@mservdev,

You must be using some older/other version of the product as I still could not find the issue with latest versions (e.g v18.2.2 or v18.2.4). I think you may print the version number (at the start of your program) of the fix/version:
e.g
Sample code:

Console.WriteLine(CellsHelper.GetVersion());

If you still find the issue with latest fix/version, please create a separate console demo application (runnable) with template file, zip the project and post us here (you may exclude the Aspose.Cells assembly when zipping the project), we will check it soon.

First of all, the correct version (18.2.2) is displayed. I built you a demo, with the file and without the Cells Assembly.

Sample
BugDemo.zip (11.4 KB)

Thanks for checking it out.

Same error with version 18.2.4.

@mservdev,

Thanks for the sample project with template file.

This time I am able to reproduce the issue using your template file, may be I used the right ODS file now. Anyways, I have logged a ticket with an id “CELLSNET-45950” for your issue. The ticket is logged as following:

  • CELLSNET-45950 - Exception “ReadElementString only could be called when the content is simple or empty” when loading an ODS file

Once we have an update on it, we will let you know here.

1 Like

@mservdev

Thanks for using Aspose.Cells.

Please download and try the following fix and let us know your feedback.

@shakeel.faiz
It works, thank you very much! There’s one thing that struck me. If you are reading my sample file, please pay attention to A13-B13.

A13
Formula: =SU
Display value in Excel: #NAME?
DisplayStringValue in Cells: 0

B13
Formula: C18:C19
Display value in Excel: #VALUE!
DisplayStringValue in Cells: 00. Dez

Maybe this is just a characteristic of ODS?

@mservdev,

Good to know that your issue is resolved by the new fix/version.

Please call Workbook.CalculateFormula() method before reading the values from the cells:
e.g
Sample code:

Workbook book = new Workbook(“e:\test2\ErrorOpening.ods”); //Cells Version 18.2.0
book.CalculateFormula();
Worksheet worksheet = book.Worksheets[0];
Cells cells = worksheet.Cells;
Cell cell1 = cells[“A13”];
Cell cell2 = cells[“B13”];

Let us know if you still find the issue.

1 Like

Thanks, that was the solution :slight_smile:

@mservdev,

Good to know that the suggested line of code figures out your issue now. Feel free to write us back if you have further comments or questions, we will be happy to assist you soon.

Hi,

I’m having the same error in the Java version of Aspose Cells, version 18.2.0. I have attached the file to this post. Is there a fix for this?

Cheers.

ods.zip (9.5 KB)

@simon.wiseman,

Thanks for the sample ODS file.

I think you are using Aspose.Cells for Java APIs. I am able to reproduce the issue using your template file to be loaded by Aspose.Cells for Java Workbook object. I have logged a ticket with an id “CELLSJAVA-42545” for your issue. The ticket is logged as following:

CELLSJAVA-42545 - Exception “ReadElementString only could be called when the content is simple or empty” when loading an ODS file by Aspose.Cells for Java.
e.g
Sample code:

Workbook book = new Workbook("e:\\test2\\ods.ods");

Once we have an update on it, we will let you know here.

@simon.wiseman

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSJAVA-42545 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

@shakeel.faiz

I found another bug in my ODS file example. When you open the file in Excel, cell C3 has the following text: 8:15:00 PM and value: 12.05.2028 20:15:00

But Cells gives me the following text: 8:13:08 PM and value: 12.05.2028 20:13:07

Could you please take a look at this?

@mservdev,

I did try your scenario/case using your file with our latest version/fix (Aspose.Cells for .NET v18.2.6) and I do not get this issue on my end, see the screenshot for your reference:

I have downloaded 18.2.6 but still got the same problem. I have attached you my sample (7.7 KB) that got problems.

@mservdev,

Thanks for the screenshot and sample file.

That is strange as I do not get this issue with your new file and sample code (in the screenshot I shared in my previous post). What is your locale/regional settings set on the machine, could you provide details for your OS/environment where you are executing the task. My environment is: OS: Windows 8, regional/local settings: English (Singapore ), etc.

@Amjad_Sahi

OS: Windows 10
Region/local: German (Germany)

Or do you need more specific information?