简体   繁体   English

经典ASP中的Excel导出

[英]Excel Export in Classic ASP

I am asked to look at an issue in Prod in a classic ASP application. 我被要求在经典的ASP应用程序中查看Prod中的一个问题。 The excel export of data is not working. Excel数据导出无效。 I seek your help as I do not have good experience in classic asp. 我没有经典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: 在/ WebFramework /文件夹中有一个名为content.xls的excel文件,它被写入excel文件中:

    <%
    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? 1.是否需要在新服务器上安装excel?

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? 2.由于我们正在创建.xls,是需要安装旧版本的excel还是需要使用新版本的excel创建一个具有相同内容的新.xls文件?

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? 3.如果这需要安装较旧版本的excel,并且服务器为2012,那么由于无法安装较旧版本的excel,我们可以注册任何com组件吗?

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? 4.OR,如果需要更改代码,是否需要更改content.xls文件中的代码以与较新的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: 首先将content.xls更改为content.asp,然后将代码更改如下:

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

Within the content.asp, changed the code to: 在content.asp中,将代码更改为:

    <%
    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: 首先将content.xls更改为content.asp,然后将代码更改如下:

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

Within the content.asp, changed the code to: 在content.asp中,将代码更改为:

    <%
    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. 如果有的话,请分享其他替代答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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