I generate an excel file using XML format outlined on stackoverflow in the following post:
Generate excel file in .net
However, when I open it up in excel 07, I get the following message:
The file you are trying to open,
“blah.xls”, is in a different format
than spefied by the file extension.
Verify that the file i snot corrupted
and is from a trusted source before
opening the file. Do you want to open
the file now?
What is causing the error message and how can I get rid of it? Thanks!
Try calling the file
blah.xlsxinstead ofblah.xls. Excel apparently wants XML files to have an “xlsx” extension. The “xls” extension is for the binary format files.Edit in response to your comment:
I was wrong:
xlsxfiles aren’t just the XML files, they’re zip archives containing the XML format plus other metadata. All in all, it’s a little complex to set up. I’d try renaming the file toblah.xml, and see if that works. Otherwise I’m afraid you might have to look at how to make these zip files. There are two options:xlsxfiles above what part 2 says you need, so read part 2 first, then part 1.