Error while opening xls file

Hi,


I’m trying to open a xls file generated by a software and I have the following error:
“This file’s format is not supported or you don’t specify a correct format.”.

Here the code I use to open it :
Workbook workbook = new Workbook(“PathOfTheFile”);


If I open the xls file with notepad, I obtain :
"
…"
I have join an example to my post. Do you know what can I do to open this file ?

Best Regards

Hi,

Thanks for the file.

Well, your template file is not a native Excel file, it is actually a web page / html file. You may open the file into notepad and confirm it. It is an html (web) file. You have to convert it into "Microsoft Office Excel Workbook". The procedure is very simple. Open the file into MS Excel (e.g 2003/2007) and Save it As "Microsoft Office Excel Workbook". It will work fine then.

Thank you.

Hi, thank you,

But aspose is able to save the workbook in a HTML file but it can’t read it, is it ?
Do you know if there is another way, because my process need to be automatic ?

Best regards

Hi,


Yes, I am afraid you cannot read general Html files (as your template Html file) by Aspose.Cells. I am afraid there is no other way but to use my workaround at the moment.

Thank you.

Hi,

Why is it possible to open html files with aspose using java language and not with C# ?

Regards

Hi,

Well, using latest version (you may download it from here: Aspose.Cells for .NET (Latest Version) ), you can read Html files but the html files should be Excel oriented same as with Java version. The common or general html files are not supported yet.

Thank you.

Sorry,

I downloaded the last version and I tryed with an xls saved as an htm.

I tryed to open it with aspose.cell and I got an error.

"The format of the input string is incorrect."

Regards

Hi,


I tried with a sample native XLS file, I opened it and saved it as “Html”. Then, I opened the saved “Html” again with Aspose.Cells, it works fine.
Here is my sample code:

Sample code:
Workbook wb = new Workbook(“e:\test\book1.xls”);
wb.Save(“e:\test2\outBook1.html”, SaveFormat.Html);
wb = new Workbook(“e:\test2\outBook1.html”, new LoadOptions(LoadFormat.Html)); //Works fine

Thank you.

Hi,


Please try the version/fix: Aspose.Cells for .NET (Latest Version) , we have supported/fixed your issue now.
It works fine with your template file now:

Sample code:

Workbook workbook = new Workbook(“e:\test2\Example.xls”);
MessageBox.Show(CellsHelper.DetectFileFormat(“e:\test2\Example.xls”).ToString());
MessageBox.Show(workbook.Worksheets[0].Cells[“B1”].StringValue);
workbook.Save(“e:\test2\out.xls”);

Thank you.

Hi,

thank you very much for this fix.
It works great we found just one difference from this original (TIE_OUT_PL.xls) after processing with Aspose. The cell height and the cell width were not the same.

Best regards

Hi,


Well as I told you there might some differences regarding formattings etc. while converting HTML to Excel format. I can find formatting issues as you have mentioned

Workbook workbook = new Workbook(“e:\test2\TIE_OUT_PL.xls”, new LoadOptions(LoadFormat.Html));
workbook.Save(“e:\test2\outddd.xls”, SaveFormat.Excel97To2003);

I have logged a ticket with an id: CELLSNET-40189. We will look into it if we can fix it.

Thank you.