2013-01-22 59 views
2

我已经读了很多有关此主题(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),并从我的理解“比扩展的错误不同的文件格式”,没有一个服务器端的解决了这个问题。 事情是关于这个主题的帖子的大多数都已经超过2年了导出Excel文件返回

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

    %> 

在此先感谢。

+0

请参阅http://stackoverflow.com/questions/4212861/what-is-a-correct-mim e-type-for-docx-pptx-etc –

+0

如果我添加contenttype application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,结果是一样的。 – Bernardo

回答

-1

我不认为有任何发展,特别是在经典的ASP世界。最好的办法仍是下列之一:

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

  • 教育您的用户让他们知道预计的警告