8

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>
User5910
  • 463
  • 5
  • 13
Martin Huwa
  • 401
  • 3
  • 7
  • 11
  • If you read below the article, there's a spec with the new MIME types for XML-based Office Documents... – Joel A. Villarreal Bertoldi Sep 14 '11 at 12:14
  • i already use application/vnd.ms-excel in the header – Martin Huwa Sep 14 '11 at 12:15
  • 1
    For XML formatted Excel documents you should be using `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`, which corresponds to the `.xlsx` extension. – Cᴏʀʏ Sep 14 '11 at 12:24
  • but i use .xls, when i use xlsx, do i have to change the sourcecode of the xls file? – Martin Huwa Sep 14 '11 at 12:28
  • Files with the .xls file extension are normally binary files (i.e. not human readable, as they should be if they were created with Excel 2003). The .xlsx extension is given to XML-formatted files; the ones created by Excel 2007 by default. So no, you don't have to change the source code. – Cᴏʀʏ Sep 14 '11 at 12:39
  • but xlsx can not be read above excel 2007 (2003, ...) – Martin Huwa Sep 14 '11 at 12:42
  • 2
    There was an XML-based format available in xl2003. It wasn't the zipped xlsx format, and is easier to work with if you want to create a multi-sheet workbook for download. That's the format Martin is using. – Tim Williams Sep 14 '11 at 14:48
  • I renamed the spreadsheet to an `.xml` extension and dragged it onto Office 2010 Excel's titlebar to open without warnings. I had no luck trying to `open with` Office 14's `MSOXMLED.EXE` referenced below by @Bernhard who mentioned this in the context of Office 15. – User5910 Apr 25 '20 at 16:54

1 Answers1

3

Well as the commenters already mentioned your example-document is definitely 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 opposed to the original binary/ proprietary 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 processing instruction). Maybe on your machine this works as it was intended to work (otherwise you might have to change this behavior).

So this is basically the same the other commenters already said. Still I hope this helps.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Andreas J
  • 526
  • 4
  • 18
  • after installing office the .xml extension should be opened by "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15\MSOXMLED.EXE" (on x64) and this app redirects to the right office app – Bernhard Jan 17 '18 at 14:12
  • 1
    a more detailed explanation https://stackoverflow.com/a/1569619/1498669 – Bernhard Feb 07 '18 at 14:01