gpt4 book ai didi

asp-classic - 使用经典 ASP 将表数据导出到 Excel 的问题

转载 作者:行者123 更新时间:2023-12-04 05:21:42 25 4
gpt4 key购买 nike

我有一个报告页面,它有两个标签、两个下拉菜单、一个命令按钮和一个用于显示数据的表格。
问题是,在将数据导出到 excel 时,标签和下拉列表也与表格一起导出。

如何仅导出表格而不导出任何 html 控件?

最佳答案

最好通过 FileSystemObject 将表的内容导出到 Excel 文件。

例如:

    dim vPath , vRecordset
vPath = "reports/" & objFileSystem.GetTempName & ".xls"
set vRecordset= DBConnection.Execute(SqlQueryString)

set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
set objFile= objFileSystem.OpenTextFile(Server.MapPath(vPath),8,true,-1)

dim strHeader,strLine
strHeader = "<table border=1><tr>"
strLine = ""

for each col in vRecordset.fields
strHeader = strHeader &"<th bgcolor=#bed9fa><b>" & col.name & "</b></th>"
next
objFile.WriteLine strHeader & "</tr>"

do while not vRecordset.eof
strLine = "<tr>"
for each col in vRecordset.fields
strLine = strLine & "<td>" & col.value & "</td>"
next
objFile.WriteLine strLine & "</tr>"
vRecordset.movenext
loop
objFile.WriteLine "</table>"

response.write "<a href='"& vPath &"'>report download</a>"

用户下载现有文件直接响应页面所有内容会更加流畅。

关于asp-classic - 使用经典 ASP 将表数据导出到 Excel 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13615323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com