Warning message when opening created Excel file in office 07

I am creating an excel file using the XML format described in stackoverflow in the following message: Create an excel file in .net

However, when I open it in excel 07, I get the following message:

The file you are trying to open, "blah.xls", is in a different format than indicated by the file extension. Make sure that the flash file is damaged and that the file is opened from a reliable source. Do you want to open the file now?

What causes the error message and how can I get rid of it? Thanks!

+4
source share
2 answers

Try calling blah.xlsx instead of blah.xls . Excel apparently wants the XML files to have the extension "xlsx". The "xls" extension is for binary files.

Edit in response to your comment:
I was wrong: xlsx files are not only XML files, they are zip archives containing the XML format plus other metadata. All in all, it's a little tricky to set up. I will try to rename the file to blah.xml and see if this works. Otherwise, I'm afraid you might have to see how to make these zip files. There are two options:

  • Use the Microsoft OOXML SDK: see http://msdn.microsoft.com/en-us/library/bb448854.aspx .
  • Do it yourself (much harder). You should look at the OOXML standard . Part 1 provides an overview and description of each XML file. Part 2 describes the package format (i.e., the ZIP archive format). There are additional requirements for xlsx files over what you need 2, so read part 2 first, then part 1.
+4
source

Office Microsoft Office 2007 on computers, office files are stored in xml format (office xml-package). Earlier versions (2003 and below) are not saved as xml files. This way you do not see the markup of the xls files. You can see the markup of the xlsx file. You do not need any editors. If WinRar is installed on your system, this is enough to open any MS-Office file.
If you try to open it programmatically, you will get the DocumentFormat.xml.dll library (its free) (for .net) and OpenXml4J (for java).

0
source

All Articles