ASP导出EXCEL,如何自定义表头。

gongpailj gongpailj 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

Set fs = server.CreateObject("scripting.filesystemobject")
filename="stock_list.xls"
temp=filename
filename=server.MapPath("excel\")+filename
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
myfile.writeline strLine

while not rs.eof
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
'--将表的数据写入EXCEL
myfile.writeline strLine
rs.movenext
wend
response.redirect "excel/stock_list.xls"
set myfile = nothing
Set fs=Nothing
end if


如上,这段代码可以把数据导出,表头是按数据库的表头直接读出来的,请问,如何修改这段代码:
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
myfile.writeline strLine

我想自定义表头,比如,第一列user,第二列name,第三列dep ........
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
gongpailj
ASP 28,401 成员 356,940 内容