日期:2014-05-17  浏览次数:20992 次

请问如何将ADO取出的数据直接保存成excel文件或文本文件?
请问如何将ADO取出的数据直接保存成excel文件或文本文件?

------解决方案--------------------
s = rs.GetString(2,, ", ",VBCrLf, ' ')
用FileSystemObject 将 s写入文本文件 xxx.csv
------解决方案--------------------
'######################################################
Function OutPut(strFilePath,Mime)
Response.ContentType = Mime
Const adTypeBinary = 1
Set objStream = Server.CreateObject( "ADODB.Stream ")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
End Function
'######################################################
%>
用ASP输出Word、Excel文件


Dim Fso,FileExt,strFilePath,Mime
strFilePath = "f:\sifang\qyoa\国贸手抄.doc "
Set Fso=Server.CreateObject( "Scripting.FileSystemObject ")
FileExt = Fso.GetExtensionName(strFilePath)
Set fso=Nothing

Select Case FileExt
Case "doc "
Mime= "Application/msword "
Case "xls "
Mime= "Application/msexcel "
End Select

Call OutPut(strFilePath,Mime)