Saving to Excel97To2003 cause error when opening .xls file

When I call the Workbook.Save(string filename, SaveFormat.Excel97to2003) method I get an error that pops up when I open the file in Excel 2007.

Error the pops up is "File error: data may have been lost"

It opens okay, just has this error when opening the spreadsheet.

Works perfectly when saving to .xlsx document type. using Workbook.Save(string filename, SaveFormat.Xlsx)

Hi,

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

Please download and use the latest version:
Aspose.Cells
for .NET v7.2.0.2
and see if it resolves your problem.

If problem still occurs, then we will need your source (xls/xlsx) file and the full sample code replicating the problem, so that we could run it and test your issue.

I am unable to download the attachment. I get a response that the page doesn’t exist.

Hi,

The above version is now older.

Please download the latest version from this link:
Aspose.Cells
for .NET v7.2.0.4

I have users that use Blackberries and open Excel documents with Documents to Go. When I send out Excel files with the xlsx extension they are unable to open the document. They get a message that states "This file cannot be opened because it is not a valid MS Excel 97-2008 file."

If I save the file as xls extension they can open these now with this version.

Also, if I open the file on my desktop and save the file as .xlsx and send it out the Blackberry users can open my version, but not the one from Cells.

Any ideas?

Hi,

Please note, Xlsx is a newer format i.e Ms-Excel 2007/2010 format.

But the Xls is an older format i.e Ms-Excel 2003 format.

So if you want to generate your file in Xlsx format, you will have to save your workbook like this.

C#


workbook.Save(“output.xlsx”, SaveFormat.Xlsx);

I agree about the newer format, but in a previous version of Aspose.Cells I was able to save as workbook.Save(“output.xlsx”, SaveFormat.Xlsx); and the files could be opened on the Blackberries. With version 7.2.0.4 all files that are sent in xlsx format throw the error I stated previously.

Hi,

Thanks for your feedback.

I have generated the output.xlsx file using the following code with the latest version at my end.

Please download it and try opening it at your end in Blackberries and let me know your feedback.

C#


Workbook workbook = new Workbook();


workbook.Save(“output.xlsx”, SaveFormat.Xlsx);

This didn't work either. Got the same error message. I've attached a picture of the error message.

I previously had version 5.3.0 and it worked with no issues. With xlsx files.

Hi,

Thanks for your testing and providing us a screenshot of error.

I have logged it as a bug in our database. Development team will look into it and fix the problems.

Once, the issue is fixed or we have any other update for you, we will let you know asap.

This issue has been logged as CELLSNET-40640.

Hi,

Please set OoxmlSaveOptions.ExportCellName property.

C#


Workbook workbook = new Workbook();

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();

saveOptions.ExportCellName = true;

workbook.Save(@“D:\FileTemp\dest.xlsx”, saveOptions);

This didn’t fix the issue on my end. Still get the same error.

Hi,

Thanks for your feedback.

It’s strange that you still get the issue. I have logged your comment in our database against the issue id: CELLSNET-40640 for investigation.

We will get back to you asap.

Hi,

For your issue, please create two simple xlsx files, one is created by 5.3.0 and can work. Another is created by the latest version and cannot work. We will look into them to figure the issue out.

Sorry for the delay. Here are to two files you requested.

The file labeled with 5.3 is from version 5.3.0 and works on our Blackberries in Sheets to Go.

The file labeled with 7.2.0.4 is from version 7.2.0.4 and does not work on our Blackberries in Sheets to Go.

Here is the code used for each file:

Aspose.Cells.

License l = new License();

l.SetLicense(

@".\Aspose.Cells.lic");

Workbook wb = new Workbook();

Worksheet ws = wb.Worksheets[0];

ws.Cells[0, 0].PutValue(

"This is a test");

ws.Cells[1, 0].PutValue(1);

ws.Cells[2, 0].PutValue(2);

ws.Cells[3, 0].PutValue(3);

ws.Cells[4, 0].PutValue(4);

ws.Cells[5, 0].PutValue(5);

ws.Cells[6, 0].PutValue(6);

ws.Cells[1, 1].PutValue(2);

ws.Cells[2, 1].PutValue(3);

ws.Cells[3, 1].PutValue(4);

ws.Cells[4, 1].PutValue(5);

ws.Cells[5, 1].PutValue(6);

ws.Cells[6, 1].PutValue(7);

ws.Cells[7, 0].PutValue(

"Finished");

wb.Save(@".\ApsoseTest.7.2.0.4.xlsx", SaveFormat.Xlsx);

Hi,


Thank you for providing us the supporting files. We have forwarded this information to our concerned developers and will get back to you once we get update about it.

We appreciate your continuous feedback

Hi,


By the way, could you add a few lines to your code and check if it works fine now:

Updated Sample code:

License l = new License();

l.SetLicense(

@".\Aspose.Cells.lic");

Workbook wb = new Workbook();

Worksheet ws = wb.Worksheets[0];

ws.Cells[0, 0].PutValue(

“This is a test”);

ws.Cells[1, 0].PutValue(1);

ws.Cells[2, 0].PutValue(2);

ws.Cells[3, 0].PutValue(3);

ws.Cells[4, 0].PutValue(4);

ws.Cells[5, 0].PutValue(5);

ws.Cells[6, 0].PutValue(6);

ws.Cells[1, 1].PutValue(2);

ws.Cells[2, 1].PutValue(3);

ws.Cells[3, 1].PutValue(4);

ws.Cells[4, 1].PutValue(5);

ws.Cells[5, 1].PutValue(6);

ws.Cells[6, 1].PutValue(7);

ws.Cells[7, 0].PutValue(

“Finished”);


OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();

saveOptions.ExportCellName =
true;

wb.Save(

@".\ApsoseTest.7.2.0.4.xlsx", saveOptions);


I made the changes as instructed and I still get the same error message as before.

I'm also attaching the new file.

Hi,


Thanks for providing us the new file (after adding the suggested lines to your source code).

I have reopened your issue again. We will look into it. Once we have any update, we will let you know here.

Thank you.

Hi,

We have fixed this issue.

Please download and try the latest fix: Aspose.Cells for .NET v7.2.1.1