Hi,
I’m trying to use Aspose Cells to save an xls file as an OpenXml compatible xlsx file.
I’ve tried a few combinations of the SaveOptions and SaveFormat but it always creates a file that doesn’t seem to be OpenXML.
e.g. workbook.Save(@“C:\ExcelConversion\test.xlsx”, Aspose.Cells.SaveFormat.Xlsx);
The resulting file needs to be passed on to other existing code that reads it using OpenXML libraries, but the exception “File contains corrupted data.” occurs on open.
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(@“C:\ExcelConversion\test.xlsx”, true)
I’ve also noticed that if I change the xlsx extension to zip I can’t open it like I normally can. Windows Explorer complains.
Is what I’m trying to do actually possible with Aspose?
Thanks.
Andrew.
Hi,
Please try our latest version/fix: Aspose.Cells for .NET v8.4.1 (if you are not already using it, you may download it from
Downloads module).
If you still find the issue, kindly do provide your template XLS file so we could re-save the file to XLSX file format via Aspose.Cells APIs.
FYI, Aspose.Cells does follow MS Excel standards and specifications. The files produced by Aspose.Cells APIs should be opened fine into MS Excel (97-2003 (XLS) and 2007 - 2010 and 2013 (XLSX), see the document here for your reference). If you find an issue opening the generated file (by Aspose.Cells APIs) into Ms Excel, it could a bug and we need to sort it out soon.
Thank you.
Hi Andrew,
Thank you for contacting Aspose support.
I have evaluated your presented scenario while using the latest version of
Aspose.Cells for .NET 8.4.1 to convert a XLS type spreadsheet to XLSX format and then load it in an instance of
SpreadsheetDocument of Open XML SDK 2.5 without observing any problem. Moreover, the Open XML SDK 2.5 Productivity Tool for Office can validate the Aspose.Cells generated XLSX file without any issue.
I guess you are using some older revision of the Aspose,Cells for .NET API that could have problems. I would request you to please give a try to the latest version on your side. In case the problem persists, please provide us an executable standalone sample application along with its dependencies for further investigation in this regard.
C#
var book = new Workbook(“D:/book1.xls”);
book.Save(“D:/output.xlsx”, new OoxmlSaveOptions(SaveFormat.Xlsx));
var spreadsheetDocument = SpreadsheetDocument.Open(“D:/output.xlsx”,
true);
No luck I'm afraid. I tried with a simpler XLS file and it seems to work so it must be something specific about the one I'm trying to convert.
Could you tell me how to send you the file privately please?
The code I'm using is:
Aspose.Cells.OoxmlSaveOptions saveOptions = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.SpreadsheetML);
saveOptions.ExportCellName = true;
workbook.Save(@"C:\ExcelConversion\test.xlsx", saveOptions);
but I've tried a few different variations on this code.
Regards,
Andrew.
Hi Andrew,
I have marked this thread Private so it is now safe to upload your sample to this thread. If you are still concerned about the privacy of your sample then use the Contact button on the post window to send an email and attach your sample to it.
Please note, once you have sent the email, please confirm here as well. Thanks
Thanks Andrew, I have received your sample, and I will get back to you after performing a few tests on my side.
Hi,
Thanks for using Aspose.Cells.
MS Excel encrypted the file if the Workbook.IsProtected is true .Aspose.Cells works as MS Excel. But Open XML SDK does not support loading encrypted xlsx file.
Please set workbook.Settings.IsDefaultEncrypted as false, please see the following codes
C#
var workbook = new Workbook(inFile);
workbook.Settings.IsDefaultEncrypted = false;//
var saveOptions = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);
//saveOptions.ExportCellName = true;
workbook.Save(outFile, saveOptions);
Brilliant, works perfectly.
Thank you very much!
Happy for the thread to be made public so it can help others.
Hi Andrew,
It is good to know that you are up & running again. Please feel free to contact us back in case you need our further assistance with Aspose APIs.
Please note, this thread is now public so that other users having similar scenarios could gain benefits from it.