标题: 小弟有一个关于EXCEL的问题 [打印本页] 作者: skyhen 时间: 2006-8-28 17:34 标题: 小弟有一个关于EXCEL的问题 Dim conn,input,filename
Set Res=createobject("adodb.recordset")
Set conn= createobject("ADODB.Connection")
conn.Open "DBQ=C:\aaa.xls;DefaultDir=C:\;Driver={Driver do Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\EXCEL.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly=1;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
sql= "select * from [sheet1$]"
res.open sql,conn,2,2
Dim fso, myfile
Set fso=CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\result.txt", True)
MyFile.Close
Set myfile=fso.openTextFile("C:\result.txt",8,false)
While Not Res.eof
For i=0 to 16
if Res(i)<>" " Then
myfile.writeline Res(i)
else
myfile.writeline "数据库中这列为空 "
end if
next
myfile.writeline " "
Res.movenext
wend
myfile.close
Set input=nothing
Set conn=Nothing
Set res = nothing