从ASP导出Excel文件返回“与扩展错误不同的文件格式”

时间:2013-01-22 15:07:32

标签: excel asp-classic

我已经阅读了很多关于这个主题的内容(Excel spreadsheet generation results in "different file format than extension error" when opening in excel 2007http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx),根据我的理解,这个问题没有服务器端解决方案。 关于这个问题的大多数帖子都已经有两年多了。

是否有关于从网页导出.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

    %>

提前致谢。

1 个答案:

答案 0 :(得分:-1)

我认为没有任何进展,特别是在经典ASP世界。您最好的选择仍然是以下之一:

  • 以不同的格式输出报告,例如CSV或Excel XML,并将Response.ContentType设置为适当的MIME类型

  • 教育您的用户让他们知道预期警告
相关问题