开发者

warning when opening generated xls file in excel 2007

开发者 https://www.devze.com 2023-04-04 15:33 出处:网络
I get the following warning when opening an XML file with the ending .xls but I want to use it as xls:

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</Dat开发者_C百科a></Cell>

<Cell><Data ss:Type="Number">22123497</Data></Cell>

</Row>
</Table>
</Worksheet>
</Workbook>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消