1.導出EXCEL文件時,有些字段值的字符較多的進行換行處理
2.以字符0開始的字段不顯示0字符.
3.參數不傳遞
代碼如下:
<%
dim sqlstr
selectm=session("selectm")
selectkey=session("selectkey")
if session("selectm")="1" then
sqlstr="select * from CSZL where CS_MC='"&selectkey&"' order by CS_IDD desc "
elseif session("selectm")="2" then
sqlstr="select * from CSZL where CS_CZ='"&selectkey&"' order by CS_IDD desc"
else
sqlstr="select * from CSZL"
end if
set rs = Server.CreateObject("ADODB.Recordset")
rs.open sqlstr,conn,1
%>
<%
Set fs = server.CreateObject("scripting.filesystemobject")
filename = server.MapPath("factory.xls")
filename1 = "D:\factory.xls"
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
set myfile = fs.CreateTextFile(filename,true)
set myfile1=fs.createtextfile(filename1,true)
dim strLine
strLine=""
strline = strline & "名稱" & chr(9) & "聯絡人" & chr(9) & "傳真" & chr(9) & "電話" & chr(9) & "EMAIL" & chr(9) & "公司地址" & chr(9) & "產品介紹" & chr(9) & "材質" & chr(9) & "價格" & chr(9) &"報價時間" & chr(9)
myfile.writeline strLine
myfile1.writeline strLine
if not rs.eof then
Do while Not rs.EOF
strLine=""
strLine = strLine & rs("CS_MC")& chr(9) & rs("CS_LLR")& chr(9) & rs("CS_FAX") & chr(9) & rs("CS_TEL")& chr(9) & rs("CS_EMAIL")& chr(9) & rs("CS_DZ")& chr(9) & rs("CS_CPJS")& chr(9) & rs("CS_CZ")& chr(9) & rs("CS_JG")& chr(9) & rs("CS_BJSJ")& chr(9)
myfile.writeline strLine
myfile1.writeline strLine
rs.MoveNext
loop
end if
set myfile = nothing
set myfile1=nothing
Set fs=Nothing
rs.Close
set rs = nothing
conn.close
set conn=nothing
%>
[此贴子已经被作者于2005-12-6 18:23:37编辑过]