经典ASP中的Excel导出

经典ASP中的Excel导出,excel,asp-classic,export-to-excel,content-type,Excel,Asp Classic,Export To Excel,Content Type,我被要求查看经典ASP应用程序中Prod中的一个问题。excel数据导出不起作用。我寻求您的帮助,因为我在经典asp方面没有很好的经验。以下是用代码编写的内容: Session("aviAF_ExcelExporter") = buff.Contents() Response.Redirect("/WebFramework/content.xls") 在/WebFramework/文件夹中有一个名为content.xls的excel文件,它写在excel文件中: <

我被要求查看经典ASP应用程序中Prod中的一个问题。excel数据导出不起作用。我寻求您的帮助,因为我在经典asp方面没有很好的经验。以下是用代码编写的内容:

    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.xls")
在/WebFramework/文件夹中有一个名为content.xls的excel文件,它写在excel文件中:

    <%
    Response.ContentType = "application/ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>
在content.asp中,将代码更改为:

    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>
    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>
现在正按预期导出到excel


谢谢你调查。如果您有其他答案,请与我分享。

以下解决方案对我有效:

先将content.xls更改为content.asp,然后更改代码,如下所示:

    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.asp")
    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.asp")
在content.asp中,将代码更改为:

    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>
    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>
现在正按预期导出到excel

谢谢你调查。如果您有其他答案,请与他人分享。

asp interpeder可能无法传递.xls扩展名。现在,您所有的问题都取决于您是否真的发送xls数据,或要求从excel导入它们的html数据。