【发布时间】:2013-01-22 15:07:31
【问题描述】:
我已经阅读了很多关于这个主题的内容(Excel spreadsheet generation results in "different file format than extension error" when opening in excel 2007 和http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx),据我了解,这个问题没有服务器端的解决方案。 问题是关于这个主题的大多数帖子现在都有 2 年多的时间了。
关于从网页导出 .xls 和 .xlsx 文件是否有任何进展?是使用 .csv 等其他格式的唯一解决方案吗?
这是我目前拥有的代码,除了 Excel 消息之外,它可以正常工作
<%
Dim objExXML
Dim objExXSL
set objExXML = Server.CreateObject("Microsoft.XMLDOM")
objExXML.async = false
objExXML.loadxml(session("variable"))
set objExXSL = Server.CreateObject("Microsoft.XMLDOM")
objExXSL.async = false
objExXSL.load(Server.MapPath("file_test.xsl"))
Dim excelStr
excelStr = objExXML.transformNode(objExXSL)
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "Attachment; filename=file.xlsx"
Response.Write excelStr
%>
提前致谢。
【问题讨论】:
-
如果我添加内容类型 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 结果是一样的。
标签: excel asp-classic