Free Support Forum -

XLSX to XLS (Excel 97-2003) Conversion with Aspose.Cells for .NET API

We use Aspose Cells. NET v. to convert XLSX to XLS follows:

Stream stream;

var workbook = new Workbook(stream);
foreach (Worksheet worksheet in workbook.Worksheets)
worksheet.Zoom = 100;
workbook.Save(stream, new XlsSaveOptions(SaveFormat.Excel97To2003));

If the width of the columns in the source XLSX document set as the defaultColWidth and it’s value is less than 0.8, then a collection of columns worksheet.Cells.Columns will be empty.
For example, it’s happens when xl/worksheets/sheet1.xml in XLSX file contains

As a result, output file (XLS) is a zero number of columns and we do not see the data. The width of all columns are set to 0. The values ​​worksheet.Cells.StandartWidth, worksheet.Cells.StandartWidthInch, worksheet.Cells.StandartWidthPixel also equal to 0. However, set these properties correctly does not work: setting of 5 pixels for worksheet.Cells.StandardWidthPixels, the output we have more than 5.

If you put defaultColWidth = “0.8” in sheet1.xml, then XLSX to XLS file converted correctly, but we need to set default width to 0.7109375 in this example.

Note, if XLSX file open in MS Excel 2010 and change width value for all columns to any, and then return back to the original value, then conversion is correctly and in sheet1.xml added following code:


Thanks for providing us details.

Please attach your sample input Excel file (XLSX) and saved/output XLS file by Aspose.Cells APIs. Also, give us your expected file (you may re-save the XLSX file to XLS in MS Excel manually). We will check your issue soon. Also do you use the same code snippet you pasted here or you add some more or extra lines to it (if this is the case, kindly give us the complete runnable code here). Moreover, if you could go extra mile, you may also provide us some screen shots comparing the input file’s source .xml file and output file(s) to highlight the issue more, it would help us to trace down the issue more accurately.

Thank you.

Attached please find:

Input.xlsx - input XLSX file

Output.xls - output XLS file (as produced by Aspose.Cells)

Expected.xls - expected XLS file (input XLSX file saved by Excel)

Input XML.jpg - input XLSX source XML

Modified XML.jpg - modified input XLSX file (which Apose.Cells saves correctly)

As to the code snippet we confirm it's exactly the same we use.


Thanks for providing us the sample files and screen shots.

After an initial test, I can notice the issue as you have mentioned. I used the following code using your “Input.xlsx” file and save it as XLS file (setting zoom for each worksheet to 100). When I opened the output file into MS Excel 2007, there is no data displayed for the first worksheet. However as you mentioned, if we do the same operation in MS Excel 2007 (XLSX to XLS (with setting each worksheet’s zoom to 100)) manually, the data does displayed fine.

Sample code:

var workbook = new Workbook(@“E:\test2\1\Input.xlsx”);
foreach (Worksheet worksheet in workbook.Worksheets)
worksheet.Zoom = 100;
workbook.Save(@“E:\test2\1\myoutput.xls”, new XlsSaveOptions(SaveFormat.Excel97To2003));

I have logged a ticket with an id “CELLSNET-41290” for your issue. We will look into your issue soon.

Thank you.

The issues you have found earlier (filed as CELLSNET-41290) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.