Excel displays different format message for XLS extension

I am evaluating the PDF to XLS feature (using a temp 30 day license) and while it produces an XLS file, I get a message “The file you are trying to open … is in a different format than specified by the file extension” when I try to open the result in Excel.


Obviously I don’t want this message to appear. The issue occurs with Excel 2007 but I have not tested with other versions. The XLS file produced by Aspose.Pdf is attached.

Hi Richard,


Thanks for contacting support.

Yes I have managed to notice the error message when viewing the XLS file. Can you please share the source PDF so that we can test the conversion at our end. We are sorry for this inconvenience.

PS, we observed that this error appears for most of the files, but we need to try using the PDF file which you are using.

Hi Richard,


We have further investigated the issue and would like to update you that it is not a bug of Aspose.Pdf. It is expected behavior, as this message appeared because Aspose.Pdf provides saving in MS Excel 2003 XML format. While user code uses .xls file extension for output file, it is correct for lower versions of MS Excel. Versions MS Excel 2007 and higher expect .xls file extension for binary document of lower versions Excel, and *.xml for XML that.

If you save an Excel document as xml with .xls extension in MS Excel 2003, and then try open it in MS Excel version 2007 or higher this results warning message described. To avoid this warning message you can change output file extension to xml and may open opened in MS Excel version 2007 and higher without any warning messages.

// load PDF document<o:p></o:p>

Aspose.Pdf.Document
doc = new Aspose.Pdf.Document(myDir

  • “Job+Listing.pdf”);<o:p></o:p>

    // instantiate ExcelSave Option object<o:p></o:p>

    Aspose.Pdf.ExcelSaveOptions
    excelsave = new ExcelSaveOptions();<o:p></o:p>

    excelsave.UniformWorksheets = true;<o:p></o:p>

    // save the output in XLS format<o:p></o:p>

    doc.Save(myDir + “PDFtoExcel2007.xml”,
    excelsave);<o:p></o:p>

Please feel free to contact us for any further assistance.


Best Regards,

Thanks Tilal. Thanks for the workaround, but it really is not a solution. I see now that the file is saved as an XML spreadsheet and not native XLS.


Changing the extension to XML gets rid of the message (see attached) but the file is no longer associated with Excel so the user has to keep track of this themselves. I experimented and found that by inserting the the following line actually associates the file and makes the process more palatable as Excel will open the file by default:
<?mso-application progid="Excel.Sheet"?>

My new question is this: Do you see any problem with simply inserting this line after generating the XML file? If not, why can’t this be included as an option and done automatically by the Aspose.Pdf component?

Additionally, it seems to me that the sample code that is provided by Aspose gives the impression that all you need to do is save the document as “Output.xls” and Excel will open it. This is not the case because the user gets a nasty message saying the file could be corrupted and should be from a trustworthy source. I have attached the message that excel displays to the user and I am sure you will agree that many users would be worried receiving such as error.


Hi Richard,

Thanks for your feedback.

ricjamnev:

Changing the extension to XML gets rid of the message (see attached) but the file is no longer associated with Excel so the user has to keep track of this themselves. I experimented and found that by inserting the the following line actually associates the file and makes the process more palatable as Excel will open the file by default:
<?mso-application progid="Excel.Sheet"?>

My new question is this: Do you see any problem with simply inserting this line after generating the XML file? If not, why can't this be included as an option and done automatically by the Aspose.Pdf component?

We have logged an enhancement ticket PDFNEWNET-37425 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue.

Best Regards,

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


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