【发布时间】:2010-07-23 15:21:47
【问题描述】:
我已经在生成一个包含 2 个工作表的 excel XML 文件 (.xml)。
问题 #1:
下载 XML 文件的人不知道在 Excel 中打开文件。 (他们会抱怨。)
解决方案 #1:
我将文件重命名为 .XLS 而不是 .XML。
问题 #2:
在 Excel 中打开文件时出现此错误:
The file you are trying to open, ‘XXX.xls’ 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.
解决方案 #2:
以某种方式将 XML 文件转换为 XLS 文件。
所以我来找你了……
目标:
他们需要能够通过双击打开文件。 我不想使用某些 3rd 方库重建 excel 文件。
想法:
也许可以使用以下工具将 XML 转换为 xls:
http://npoi.codeplex.com/
http://excelpackage.codeplex.com/
我需要一些实现这一目标的最简单、最精简的示例代码。
还有其他想法吗?
【问题讨论】:
-
看看microsoft.com/downloads/…它是一个微软的xml下载,可以和excel一起工作。不确定它是否能提供您需要的一切,因为我以前没有使用过。
标签: c# xml excel openxml export-to-excel