如何在ASP网页中设置excel单元格的格式为文本
<%Response.ContentType="application/msexcel"filename=year(now())&"-"&right("0"&month(...
<%
Response.ContentType= "application/msexcel"
filename=year(now()) & "-" & right("0" & month(now()),2) & "-" & right("0" & day(now()),2)
response.AddHeader "content-disposition", "inline; filename=学生证书信息"&filename&".xls" '其中report.xls是你要存的文件名
response.Write("<table border=1 cellpadding=2 cellspacing=0 bordercolor=#cccccc bordercolordark=#FFFFFF" )
response.Write(" bordercolorlight=#cccccc width=100% >")
response.Write(" <tr align=center> ")
response.Write("<td><b>学号</b></td> ")
response.Write("<td><b>姓名</b></td> ")
response.Write("<td><b>性别</b></td> ")
response.Write("<td><b>身份证号</b></td> ")
response.Write("<td><b>院系</b></td> ")
response.Write("<td><b>专业</b></td> ")
response.Write("<td><b>班级</b></td> ")
response.Write("<td><b>学历</b></td> ")
response.Write("<td><b>获取证书</b></td> ")
response.Write("<td><b>获取时间</b></td> ")
response.Write("<td><b>发证机关</b></td> ")
response.Write("<td><b>是否核心证书</b></td> ")
response.Write("<td><b>备注</b></td> ")
response.Write("</tr>")
'=====================================================
Set Rs=Conn.Execute("Select * From XcUserInfo")
Do while Not Rs.eof
set rsy=conn.execute("select * from userzs where userid="&rs("id"))
do while not rsy.eof
Response.Write("<tr>")
'===========================
response.Write("<td>"&rs("UNumber")&"</td>")
response.Write("<td>"&rs("UserName")&"</td>")
response.Write("<td>"&rs("Usex")&"</td>")
response.Write("<td>"&rs("carid")&"</td>")
set rsx=conn.execute("select * from XcDepartMent where id="&rs("yx"))
if rsx.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("DepName")&"</td>")
end if
set rsx=conn.execute("select * from XcDepartMent where id="&rs("zy"))
if rsx.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("DepName")&"</td>")
end if
set rsx=conn.execute("select * from XcClass where id="&rs("bj"))
if rsx.eof then
response.Write("<td>未知</td>")
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("ClassName")&"</td>")
response.Write("<td>"&rsx("CTeacher")&"</td>")
end if
set rsxy=conn.execute("select * from zhengshu where id="&rsy("zsid"))
if rsxy.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsxy("zsmc")&"</td>")
end if
response.Write("<td>"&rsy("addtime")&"</td>")
if rsxy.eof then
response.Write("<td>未知</td>")
response.Write("<td>否</td>")
else
response.Write("<td>"&rsxy("fzjg")&"</td>")
if rsxy("ish")="1" then
response.Write("<td>是</td>")
else
response.Write("<td>否</td>")
end if
end if
response.Write("<td>"&rsy("bz")&"</td>")
Response.Write("</tr>")
Rsy.Movenext
loop
Rs.movenext
loop
response.Write("</table>")
%>
通过这个ASP网页导出EXCEL表之后,学号前面的0都不见了。而且身份证号也显示不正确,请问如何把这个EXCEL表的所有单元格都设置成文本型的? 展开
Response.ContentType= "application/msexcel"
filename=year(now()) & "-" & right("0" & month(now()),2) & "-" & right("0" & day(now()),2)
response.AddHeader "content-disposition", "inline; filename=学生证书信息"&filename&".xls" '其中report.xls是你要存的文件名
response.Write("<table border=1 cellpadding=2 cellspacing=0 bordercolor=#cccccc bordercolordark=#FFFFFF" )
response.Write(" bordercolorlight=#cccccc width=100% >")
response.Write(" <tr align=center> ")
response.Write("<td><b>学号</b></td> ")
response.Write("<td><b>姓名</b></td> ")
response.Write("<td><b>性别</b></td> ")
response.Write("<td><b>身份证号</b></td> ")
response.Write("<td><b>院系</b></td> ")
response.Write("<td><b>专业</b></td> ")
response.Write("<td><b>班级</b></td> ")
response.Write("<td><b>学历</b></td> ")
response.Write("<td><b>获取证书</b></td> ")
response.Write("<td><b>获取时间</b></td> ")
response.Write("<td><b>发证机关</b></td> ")
response.Write("<td><b>是否核心证书</b></td> ")
response.Write("<td><b>备注</b></td> ")
response.Write("</tr>")
'=====================================================
Set Rs=Conn.Execute("Select * From XcUserInfo")
Do while Not Rs.eof
set rsy=conn.execute("select * from userzs where userid="&rs("id"))
do while not rsy.eof
Response.Write("<tr>")
'===========================
response.Write("<td>"&rs("UNumber")&"</td>")
response.Write("<td>"&rs("UserName")&"</td>")
response.Write("<td>"&rs("Usex")&"</td>")
response.Write("<td>"&rs("carid")&"</td>")
set rsx=conn.execute("select * from XcDepartMent where id="&rs("yx"))
if rsx.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("DepName")&"</td>")
end if
set rsx=conn.execute("select * from XcDepartMent where id="&rs("zy"))
if rsx.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("DepName")&"</td>")
end if
set rsx=conn.execute("select * from XcClass where id="&rs("bj"))
if rsx.eof then
response.Write("<td>未知</td>")
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsx("ClassName")&"</td>")
response.Write("<td>"&rsx("CTeacher")&"</td>")
end if
set rsxy=conn.execute("select * from zhengshu where id="&rsy("zsid"))
if rsxy.eof then
response.Write("<td>未知</td>")
else
response.Write("<td>"&rsxy("zsmc")&"</td>")
end if
response.Write("<td>"&rsy("addtime")&"</td>")
if rsxy.eof then
response.Write("<td>未知</td>")
response.Write("<td>否</td>")
else
response.Write("<td>"&rsxy("fzjg")&"</td>")
if rsxy("ish")="1" then
response.Write("<td>是</td>")
else
response.Write("<td>否</td>")
end if
end if
response.Write("<td>"&rsy("bz")&"</td>")
Response.Write("</tr>")
Rsy.Movenext
loop
Rs.movenext
loop
response.Write("</table>")
%>
通过这个ASP网页导出EXCEL表之后,学号前面的0都不见了。而且身份证号也显示不正确,请问如何把这个EXCEL表的所有单元格都设置成文本型的? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询