I get the following warning when opening an XML file with the ending .xls
but I want to use it as xls
:
"The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" (Yes | No | Help)
Quoted from the MSDN blog article 'Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site' archive link original link (broken).
How to solve this?
I use .xls with this source code:
<?xml version="1.0" encoding="utf-8"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="Export">
<Table>
<Row>
<Cell><Data ss:Type="Number">3</Data></Cell>
<Cell><Data ss:Type="Number">22123497</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
The most common reason for this problem: Excel won't open a file because the file is corrupted. This is especially common if Excel crashes while saving the file, or if a problematic macro prevents the file from being saved correctly.
Click on Folder Options, then File Types, scroll down to and select (DOC for Word files) or XLS (for Excel files), click Advanced and select Open entry, click the edit Button.
On the File menu, select Options, and then select Add-Ins. In the Manage list at the bottom of the screen, select COM Add-Ins item, and then select Go. Clear one of the add-ins in the list, then select OK. Restart Excel by double-clicking the icon or file name for the workbook that you are trying to open.
Well as the commenters already mentionend your example-document is definitly not an xls-file (as those are binary) and Excel rightly complains to that fact (because a document might trick you with the wrong extension).
What you should do is to save the document with file extension xml and add the processing-instruction for an office document (or in this case SpreadsheetML as oposed to the original binary/ propriatary excel-format)
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
...
This used to work, but I just noticed that with Office 2007 the XML-processing component ("XML Editor") doesn't seem to be installed as default app for XML files. This did send XML-files to the correct application when they were opened (according to the processiong instuction). Maybe on your machine this works as it was intended to work (otherwise you might have to change this behaviour).
So this is basically the same the other commenters already said. Still I hope this helps.
Regards
Andreas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With