2024年6月21日发(作者:)
ASP将access数据导出为excel电子表的方法
有一个客户要求后台生成大数据量(每次生成几万条)的会员卡号及密码,金额等。
生成的会员卡号及密码要印制在卡上对会员发放。生成大量数据在库中,印制卡片的厂家要
拿到数据进行印制怎么办呢?
于是我想到用代码将access中的数据生成Excel表格导出。打印这样不就可以了吗?
在网上查找相关资料可都不尽如我意,就自己动手写了这个程序。现放出来供大家分享!大
家知道写代码很辛苦,所以要用或者转贴时一定注明出处:
下面为代码:
以下为引用的内容:
<%
if session("china_admin")="" then ct ""
dbpath="../"
dblink
dim filename,fs,myfile,x,m,n,o,link
Set fs = Object("stemobject")
Set rs = Object("set")
session("sql") = "select * from china_car"
session("sql"),conn,1,1
n=1
'==================================================================
'==============================================================建立excel文
件系统
filename = h("car/CarTable"&n&".xls") '这个是为了方便,新建一个
CAR的文件夹,这个可以自己设啦
if ists(filename) then'如果文件存在,覆盖它。
File(filename)
end if
set myfile = TextFile(filename,true)
'=====================================================================
===
dim strLine,responsestr
strLine=""
dim work,j,i
str="序号|卡号|密码|积分数|金额" '这个根据你的access数据表字段设置。
work=split(str,"|")
j=ubound(work)
i=0
o=0
do while not i>j
strLine= strLine & work(i) & chr(9)
i=i+1
loop
ine strLine
Do while Not
o=o+1
m=20000
strLine=""
for each x in
strLine= strLine & & chr(9)
if o>=m*n then
n=n+1
filename = h("car/CarTable"&n&".xls") '这个可以自己设啦
if ists(filename) then'如果文件存在,覆盖它。
File(filename)
end if
set myfile = TextFile(filename,true)
end if
next
ine strLine
xt
loop
set rs = nothing
set conn = nothing
set myfile = nothing
Set fs=Nothing
ExcelPath="car/CarTable"&n&".xls"
"导出成功 "
("下载
")
%>
发布者:admin,转转请注明出处:http://www.yc00.com/web/1718938015a2753695.html
评论列表(0条)