|
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
我用QTP调用EXCEL,将EXCEL的内容写入TXT文件中,但如果是中文的话,会出现问题,要么显示空白,要么显示0,请各位大虾给小弟一点建议,看看我的程序哪里还需要改进的。
我调用的EXCEL请见附件。
小弟先谢谢了 |
|