| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1677 人关注过本帖
标题:asp Excel导出格式错误问题
只看楼主 加入收藏
bhffhzh
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-8-19
结帖率:0
收藏
 问题点数:0 回复次数:0 
asp Excel导出格式错误问题
程序代码:

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <style>
p h3{font-family: "宋体"; font-weight:bold ; font-size:13px;}
table th { Height: 35px; font-family: "宋体"; font-weight:bold ; font-size:13px;  }
table td { Height: 25px; font-family: "宋体"; font-size:13px;  }
</style>
<%Response.expires = -1%>
<%Response.Buffer = true%>
<%

Dim s, sql, filename, fs, myfile, x, act, stime
act = request("act")
sgrade = Trim(request("sgrade"))'接收隐藏域传来的参数
sclass = Trim(request("sclass"))'接收隐藏域传来的参数
society = Trim(request("society"))'接收隐藏域传来的参数


file_name = sgrade&sclass&society

If file_name = "" Then
    file_name = "村居导出"
End If
 
sql = "select top 1  * from gdn  order by id desc "
Set rs = conn.Execute(sql)
kxj = rs(2) '取得开学时间

 
 
 
 
Response.AddHeader "Content-Disposition", "attachment; filename=" + file_name + ".xls"
Response.ContentType = "application/vnd.ms-excel"
 
 

%>

<body>
<h3 align="center">农村留守儿童交接名单&nbsp;(<% =file_name %>) </h3>
<table width="850" height="292" border="1" align="center"  >
  <tr style="font-weight:bold;" >
    <td colspan="7" rowspan="2" align="center" valign="middle">学生情况</td>
    <td colspan="7" align="center" valign="middle">监护情况</td>
    <td rowspan="3" align="center" valign="middle">联系电话</td>
  </tr>
  <tr style="font-weight:bold;" >
    <td colspan="3" align="center" valign="middle">实际监护人</td>
    <td colspan="4" align="center" valign="middle">法定监护人</td>
  </tr>
  <tr style="font-weight:bold;" >
    <td align="center" valign="middle">序号</td>
    <td align="center" valign="middle">姓名</td>
    <td align="center" valign="middle">性别</td>
    <td align="center" valign="middle">出生年月</td>
    <td align="center" valign="middle">地址</td>
    <td align="center" valign="middle">就读班级</td>
    <td align="center" valign="middle">班主任<br>姓名</td>
    <td align="center" valign="middle">班主任<br>联系电话</td>
    <td align="center" valign="middle">姓名</td>
    <td align="center" valign="middle">与该生<br>关系</td>
    <td align="center" valign="middle">联系电话</td>
    <td align="center" valign="middle">姓名</td>
    <td align="center" valign="middle">与该生<br>关系</td>
    <td align="center" valign="middle">务工地点</td>
  </tr>
    <%
Dim num
num = 1
strSql = request.Form("strSql") '接收隐藏域传来的参数
Set rstData = conn.Execute(strSql)
If Not rstData.EOF And Not rstData.BOF Then
    While Not rstData.EOF


%>
  <tr>
    <td align="center" valign="middle"><% =num %></td>
    <td align="center" valign="middle"><%=rstData("sname")%></td>
    <td align="center" valign="middle"><%=rstData("sex")%></td>
    <td align="center" valign="middle"><%=rstData("birth")%></td>
    <td align="center" valign="middle"><%

If InStr(rstData("address"), "重庆市") Then
    response.Write Replace(rstData("address"), "重庆市", "")
ElseIf InStr(rstData("address"), "") Then
    response.Write Replace(rstData("address"), "", "")

Else
    response.Write rstData("address")
End If
%></td>
    <td align="center" valign="middle"><%=rstData("sgrade")%><%=rstData("sclass")%></td>
    <td align="center" valign="middle"><%=rstData("teachername")%></td>
    <td align="center" valign="middle"><%=rstData("teachertel")%></td>
    <td align="center" valign="middle"><%=rstData("sguardian")%></td>
    <td align="center" valign="middle"><%=rstData("snexus")%></td>
    <td align="center" valign="middle"><%=rstData("stel")%></td>
    <td align="center" valign="middle"><%=rstData("fguardian")%></td>
    <td align="center" valign="middle"><%=rstData("fnexus")%></td>
    <td align="center" valign="middle"><%


= Left(rstData("fjob"), 2)



%></td>
    <td align="center" valign="middle"><%=rstData("ftel")%></td>
  </tr>

 <%
rstData.movenext
num = num + 1
Wend

%>
</table>
<p align="center"> <strong>注:本清单由学校学期初统计录入,一式两份,村(居)委员会、学校各存一份。</strong></p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
</body>
</html>
<%
End If
rstData.Close
Set rstData = Nothing
Conn.Close
Set Conn = Nothing
%>




能导出,虽然报错,但也能打开。但这报格式错误来怎么解决?

Response.AddHeader "Content-Disposition", "attachment; filename=" + file_name + ".xls"
Response.ContentType = "application/vnd.ms-excel"

有问题?求解。


[此贴子已经被作者于2020-7-16 11:00编辑过]

搜索更多相关主题的帖子: Response valign align center middle 
2020-07-16 10:58
快速回复:asp Excel导出格式错误问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033028 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved