Getting Error :..is in a different format than specified by the file extension


Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@"C:\Shibor2007.pdf");

Aspose.Pdf.ExcelSaveOptions excelsave = new ExcelSaveOptions();
doc.Save("c:/Shibor2007.xls", excelsave);

Convert Pdf to Excel, then Open the excel file:
Getting Error :
The file you are trying to open, 'Shibor2007.xls', is in a different format than specified by the file extension...

Offcie version:Excel 2007 32-bit
Platform: WindowsXP,NET Framework 2.0
Aspose:9.0.0.0

Hi Huang,


Thanks for contacting support.

While viewing the resultant XLS file, I have also managed to notice the same error message. Can you please share the source PDF file so that we can test the conversion in our environment. We are sorry for this delay and inconvenience.

the source PDF file

After converting PDF to EXCEL, EXCEL files contain a blank column.
How to remove Blank column?

Hi Huang,


Thanks for sharing the details.

I have tested the scenario of converting PDF file to Excel format and have managed to reproduce the same problem that an error message appears when viewing the resultant file in Excel 2010. Please note that this warning message of MS Excel version 2007 and higher versions is not a bug. This message appears because Aspose.Pdf supports saving the output in MS Excel 2003 XML format and using .xls file extension for output file is correct for lower versions of MS Excel. However MS Excel 2007 and higher versions expect .xls file extension for binary document of lower versions and *.xml extension for XML file.

So if we save an Excel document (.xls extension) as .xml using MS Excel 2003, and then try opening it in MS Excel version 2007 or higher versions, this results in same warning message as you described in your first post. Therefore, it is not a bug of Aspose.Pdf for .NET.

In order to avoid this warning message, you can change output file extension as specified below:

[C#]

Document doc = new Document(“c:/pdftest/Shibor2007.pdf”);<o:p></o:p>

Aspose.Pdf.ExcelSaveOptions
excelsave =
new ExcelSaveOptions();

doc.Save("c:/pdftest/ExcelPDF_Resultant.xml", excelsave);


In this case, Resultant.xml can be viewed in MS Excel version 2007 and higher versions without any warning messages. For your reference, I have also attached the resultant file generated over my end.

Kleif:
After converting PDF to EXCEL, EXCEL files contain a blank column.
How to remove Blank column?
Hi Huang,

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-36844. We will
investigate this issue in details and will keep you updated on the status of a
correction. We
apologize for your inconvenience.


However as a solution, you may consider using Aspose.Cells to remove the extra column in resultant file. My fellow worker from respective team will share the required information.

Kleif:

After converting PDF to EXCEL, EXCEL files contain a blank column.
How to remove Blank column?


Hi Huang,

Thanks for your inquiry and using Aspose.

You can use Aspose.Cells to delete any column in your Excel file. Please see the following documentation article for your reference.

( http://www.aspose.com/docs/display/cellsnet/Inserting+Deleting+Rows+and+Columns )

The issues you have found earlier (filed as PDFNEWNET-36844) have been fixed in Aspose.Pdf for .NET 9.4.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Huang,


In refernce to a above fix, we have added a new option into ExcelSaveOptions. Please, use following code snippet to suppress appearing of first blank column:

Document doc = new Document(inFile);<o:p></o:p>

ExcelSaveOptions options = new ExcelSaveOptions();

options.InsertBlankColumnAtFirst = false;

doc.Save(outFile, options);

Please feel free to contact us for any further assistance.


Best Regards,