2

I have read a lot about this subject ( Excel spreadsheet generation results in "different file format than extension error" when opening in excel 2007 and http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx) and from my understanding, there is not a server-side solution to this problem. The thing is the majority of the posts regarding this subject all have more than 2 years now.

Has there been any development regarding the export of .xls and .xlsx files from a web page? Is the only solution to use another format like .csv?

This is the code I currently have, and aside the Excel message, it works without any problem

    <%

    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

    %>

Thanks in advance.

Community
  • 1
  • 1
Bernardo
  • 531
  • 1
  • 13
  • 31
  • See http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc – Marc B Jan 22 '13 at 15:11
  • If I add the contenttype application/vnd.openxmlformats-officedocument.spreadsheetml.sheet the result is the same. – Bernardo Jan 22 '13 at 20:05

1 Answers1

-1

I don't think there have been any developments, especially in the Classic ASP world. Your best bet is still one of the following:

  • Output your report in a different format, such as CSV or Excel XML, and set Response.ContentType to the appropriate MIME type

or

  • Educate your users to let them know to expect the warning
Cheran Shunmugavel
  • 8,319
  • 1
  • 33
  • 40