[英]Display query result and export to excel using classic asp
I'm working on a small project regarding classic ASP and sql server. 我正在做一个有关经典ASP和sql服务器的小项目。
I have a drop down menu where the user can enter name, last name, etc. and it will create a query based on that and create a table displaying the result. 我有一个下拉菜单,用户可以在其中输入名称,姓氏等,它将基于该名称创建查询并创建一个显示结果的表。
What I want to add is the option to export to excel after the table is created. 我要添加的是创建表后导出到excel的选项。 I've looked at other tutorials but they all use the simple Select * from table rather than a query based on user input.
我看过其他教程,但是它们都使用简单的Select * from table而不是基于用户输入的查询。
can anyone help on this? 有人可以帮忙吗?
add 加
response.contenttype ="Application/vnd.excel"
response.addheader "Content-Disposition", "attachment; filename=excelDatei.xls"
and the browser opens the save/open/cancel dialog... 然后浏览器打开“保存/打开/取消”对话框...
is that what you want? 那是你要的吗?
Solved my question which dealt more with how to use this code. 解决了我的问题,其中更多涉及如何使用此代码。 What I ended up doing is storing the SQL query in a session variable and creating a link to a new ASP page that will connect to the database, create the Excel object, and output to it.
我最终要做的是将SQL查询存储在会话变量中,并创建一个指向新ASP页面的链接,该页面将连接到数据库,创建Excel对象并输出到该对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.