Free Support Forum - aspose.com

Saving to Excel 2007 from datatable creates corrupted file

I am using 4.8.1 and trying to save to Excel 2007. Both applications, Excel 2007 and Excel 2003 with conversion, fail to open the file and claim it is corrupted.

The code I am using:

Dim asp As New Aspose.Cells.Workbook
Dim aws As Aspose.Cells.Worksheet = asp.Worksheets.Item(0)
aws.Cells.ImportDataTable(dt, True, 0, 0)
asp.Save(“c:\temp\asql.xlsx”, Aspose.Cells.FileFormatType.Excel2007Xlsx)
asp.Save(“c:\temp\asql.xls”, Aspose.Cells.FileFormatType.Excel2003)
asp.Save(“c:\temp\asql.csv”, Aspose.Cells.FileFormatType.CSV)
asp.Save(“c:\temp\asql.pdf”, Aspose.Cells.FileFormatType.Pdf)

Only the Excel 2007 file is corrupted the rest present the data correctly.

I opened the Excel 2007 file and confirmed that the data strings do exist in the sharedStrings.xml file and are pointed to correctly within the sheet1.xml file but I also found where the problem may exist.

In the sheet1.xml file:



<c r=“A1” s=“2” t=“s”>
2564


6519


6137


6835


Many of the c elements don’t contain the r attribute which seems to be the problem.

I am able to open the Excel 2007 file in OpenOffice.org but anywhere the c element is missing the r attribute no data is available even though the v element is pointing to the correct location within the sharedStrings.xml.


Hi,

Please try the attached version attached.


If you want to export cell name to xlsx file, please set SaveOptions.ExpCellNameToXLSX option. See following code:

asp.SaveOptions.ExpCellNameToXLSX = true;

asp.Save("c:\temp\asql.xlsx", Aspose.Cells.FileFormatType.Excel2007Xlsx)

If you still has any problem, please post your generated xls and xlsx file. We will check it soon.

Thank you.

That works great! Thanks for the quick fix!