简体   繁体   中英

Excel Export in Classic ASP

I am asked to look at an issue in Prod in a classic ASP application. The excel export of data is not working. I seek your help as I do not have good experience in classic asp. Here is what is written in code:

    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.xls")

And there is an excel file in the /WebFramework/ folder, named content.xls and this is written in the excel file:

    <%
    Response.ContentType = "application/ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>

There is a server migration going on and this issue started since the application is migrated.

My questions are:

1.Do we need excel be installed on the new server?

2.Because we are creating .xls, do we need older version of excel installed or do we need to create a new .xls file with same content using the newer version of excel?

3.If this needs an older version of excel to be installed, and the server is 2012, can we register any com components instead because installed older version of excel is not possible?

4.OR, if a code change is necessary, Do we need to change the code in the content.xls file to be compatible with newer excel? If so, can someone please help on how the code needs to be changed?

Thank you very much!

UPDATE:

This following solution worked for me:

Changed the content.xls to content.asp first and then changed code as below:

    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.asp")

Within the content.asp, changed the code to:

    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>

This is now exporting as expected to excel.

Thanks for looking into. Please share any alternative answers if you have.

This following solution worked for me:

Changed the content.xls to content.asp first and then changed code as below:

    Session("aviAF_ExcelExporter") = buff.Contents()
    Response.Redirect("/WebFramework/content.asp")

Within the content.asp, changed the code to:

    <%
    Response.ContentType = "application/vnd.ms-excel" 
    Response.Write Session("aviAF_ExcelExporter") & vbCrLf
    %>

This is now exporting as expected to excel.

Thanks for looking into. Please share any alternative answers if you have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM