如何用ASP象数据库一样导入和导出*.csv文件(满分赠送)
请各位大侠帮忙,急用,最好有源码,感激不尽~ 问题点数:100、回复次数:4Top
1 楼ccmoon(IzuaL)回复于 2003-09-02 12:59:32 得分 10
你得用逗号拼接字符串
然后用fso写入csvTop
2 楼piccologoo(piccolo)回复于 2003-09-02 13:00:31 得分 45
倒入
<%
Set cnXLS = CreateObject("ADODB.Connection")
cnXLS.Open "Driver={Microsoft Excel Driver (*.xls)};ReadOnly=0;DBQ=d:\temp\csl.xls"
dim sqlXLS
sqlXLS="Select * From [Sheet1$]"
Set rstXLS = CreateObject("ADODB.Recordset")
rstXLS.Open sqlXLS,cnXLS
do while not rstXLS.eof
response.write rstXLS.fields(12) & "<br>"
rstXLS.movenext
loop
''OpenSchema方法的變量是query_type
dim adSchemaTables
adSchemaTables=20
Set rs = CreateObject("ADODB.Recordset")
set rs=cnXLS.OpenSchema(adSchemaTables)
response.write rs.recordcount
set cnXLS=nothing
set rstXLS=nothing
%>Top
3 楼piccologoo(piccolo)回复于 2003-09-02 13:01:00 得分 45
导出
<%
set fs = server.createobject("scripting.filesystemobject")
If fs.FileExists("d:\temp\test.CSV") then
fs.DeleteFile"d:\temp\test.CSV", True
End if
''不要生成unicode,會出錯
set myfile = fs.createtextfile("d:\temp\test.CSV",true)
myfile.writeline "title1" & "," & "title2" & "," & "title3"
myfile.writeline "0021" & "," & "rrwe" & "," & "0.30"
myfile.writeline "0021" & "," & "rrwe" & "," & "0.30"
myfile.close
set myfile=nothing
%>
<a href="d:\temp\test.CSV" >下載</a>Top
4 楼postform999(真水无香)回复于 2004-02-29 22:48:01 得分 0
markTop



