I generate an excel file using XML format outlined on * in the following post: Generate excel file in .net
我使用*上列出的XML格式生成了一个excel文件:在。net中生成excel文件
However, when I open it up in excel 07, I get the following message:
然而,当我在excel07中打开它时,我得到以下信息:
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?
你要打开的文件。“xls”的格式与文件扩展名的速度不同。在打开文件之前,请验证我的文件是否已被损坏,是否来自受信任的源文件。你想现在打开文件吗?
What is causing the error message and how can I get rid of it? Thanks!
是什么导致了错误消息,我如何摆脱它?谢谢!
2 个解决方案
#1
4
Try calling the file blah.xlsx
instead of blah.xls
. Excel apparently wants XML files to have an "xlsx" extension. The "xls" extension is for the binary format files.
尝试调用文件等等。xlsx代替blah.xls。显然,Excel希望XML文件有一个“xlsx”扩展。“xls”扩展用于二进制格式文件。
Edit in response to your comment:
I was wrong: xlsx
files 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 to blah.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:
编辑响应您的评论:我错了:xlsx文件不仅仅是XML文件,它们是包含XML格式和其他元数据的zip归档文件。总之,设置起来有点复杂。我会试着将文件重命名为blah。看看这是否有效。否则,恐怕你得看看如何制作这些zip文件。有两个选择:
- Use Microsoft's OOXML SDK: see http://msdn.microsoft.com/en-us/library/bb448854.aspx.
- 使用微软的OOXML SDK:参见http://msdn.microsoft.com/en-us/library/bb448854.aspx。
- Do it yourself (much harder). You'll have to look at the OOXML standard. Part 1 contains an overview, and a description of each XML file. Part 2 describes the package format (i.e. the zip archive format). There are additional requirements on
xlsx
files above what part 2 says you need, so read part 2 first, then part 1. - 你自己做(要难得多)。您必须查看OOXML标准。第1部分包含对每个XML文件的概述和描述。第2部分描述包格式(即zip归档格式)。在xlsx文件上有额外的要求,上面第2部分说您需要,所以请先阅读第2部分,然后第1部分。
#2
0
Microsoft office 2007 on wards, the office files are stored in xml format (office open xml package). Earlier versions (2003 and below) are not stored as xml files. So you cannot see markup of xls files. Off course you can see markup of xlsx file. You do not require any editors. If you have WinRar installed in your system, that is sufficient to open any MS-Office file.
If you are trying to open it programmatically, then you will get DocumentFormat.xml.dll library (its free) (for .net) and OpenXml4J (for java).
office 2007在病区上,office文件存储为xml格式(office open xml package)。早期版本(2003和以下版本)不存储为xml文件。所以您看不到xls文件的标记。当然,您可以看到xlsx文件的标记。您不需要任何编辑器。如果在系统中安装了WinRar,那么就足以打开任何MS-Office文件。如果您试图以编程方式打开它,那么您将获得DocumentFormat.xml。dll库(免费)(用于。net)和OpenXml4J(用于java)。
#1
4
Try calling the file blah.xlsx
instead of blah.xls
. Excel apparently wants XML files to have an "xlsx" extension. The "xls" extension is for the binary format files.
尝试调用文件等等。xlsx代替blah.xls。显然,Excel希望XML文件有一个“xlsx”扩展。“xls”扩展用于二进制格式文件。
Edit in response to your comment:
I was wrong: xlsx
files 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 to blah.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:
编辑响应您的评论:我错了:xlsx文件不仅仅是XML文件,它们是包含XML格式和其他元数据的zip归档文件。总之,设置起来有点复杂。我会试着将文件重命名为blah。看看这是否有效。否则,恐怕你得看看如何制作这些zip文件。有两个选择:
- Use Microsoft's OOXML SDK: see http://msdn.microsoft.com/en-us/library/bb448854.aspx.
- 使用微软的OOXML SDK:参见http://msdn.microsoft.com/en-us/library/bb448854.aspx。
- Do it yourself (much harder). You'll have to look at the OOXML standard. Part 1 contains an overview, and a description of each XML file. Part 2 describes the package format (i.e. the zip archive format). There are additional requirements on
xlsx
files above what part 2 says you need, so read part 2 first, then part 1. - 你自己做(要难得多)。您必须查看OOXML标准。第1部分包含对每个XML文件的概述和描述。第2部分描述包格式(即zip归档格式)。在xlsx文件上有额外的要求,上面第2部分说您需要,所以请先阅读第2部分,然后第1部分。
#2
0
Microsoft office 2007 on wards, the office files are stored in xml format (office open xml package). Earlier versions (2003 and below) are not stored as xml files. So you cannot see markup of xls files. Off course you can see markup of xlsx file. You do not require any editors. If you have WinRar installed in your system, that is sufficient to open any MS-Office file.
If you are trying to open it programmatically, then you will get DocumentFormat.xml.dll library (its free) (for .net) and OpenXml4J (for java).
office 2007在病区上,office文件存储为xml格式(office open xml package)。早期版本(2003和以下版本)不存储为xml文件。所以您看不到xls文件的标记。当然,您可以看到xlsx文件的标记。您不需要任何编辑器。如果在系统中安装了WinRar,那么就足以打开任何MS-Office文件。如果您试图以编程方式打开它,那么您将获得DocumentFormat.xml。dll库(免费)(用于。net)和OpenXml4J(用于java)。