Discuz!NT官方社区

首页 » Web开发 » ASP.net技术讨论 » [求助]Asp怎样设置Excel整个Sheet或某列为文本格式
hamilton - 2007-4-24 10:55:00
从数据库取出数据导入Excel时,数据开头的0会被自动省略。如01111导入Excel后变为1111
在Excel输入时可以在数据前添加半角单引号或先设置为文本格式,但在SQL中前面拼‘后,导入Excel时变成‘01111,请问如何解决。
'set download file     
Response.C     
call Response.AddHeader("Content-disposition","attachment; filename=xxx.xs")   
'select data from database
sqlstring=Session("sqlstr")
'rs.open sqlString,db,1,3
set rs=db.execute(sqlstring)
'write data into the download file
str=""
strFields=""
if not rs.eof then
for i = 0 to Rs.Fields.Count - 1
strFields = strFields+Rs(i).Name + chr(9)
next
strFields=strFields+Chr(13)+Chr(10)     
Response.Write strFields           
Response.Write rs.getstring(,,Chr(9),Chr(13)+Chr(10))
end if
'close connection
rs.CLOSE
Set rs = Nothing
戏水 - 2007-4-25 9:18:00
这个建议您到专门的asp技术讨论社区去求助 :P
1
查看完整版本: [求助]Asp怎样设置Excel整个Sheet或某列为文本格式