急需高手请教关于页面表格数据转换为WORD文档问题!

ccjh623 2010-05-24 01:02:58
下面是小弟编的页面表格数据转换为WORD文档的代码。
问题一表格上有图片格式JPG,为什么图片在页面上可以显示出来,转换为WORD就显示不出来,急需各位高手指教;
问题二小弟的页面表格数据是采用分页显示的,为什么转换为WORD文档时只转换第一页的页面表格数据而其他页的没转换,哪位高手能教下小弟怎样才能把页面数据全部转换为WORD,如果数据太多的话怎么才能使WORD分页显示。
<!--#include file="conn.asp"-->
<%
dim ljbh,ljmc,gxh
ljbh= Request.QueryString("ljbh")
ljmc=request.querystring("ljmc")
gxh=request.querystring("gxh")
%>
<%
Response.ContentType = "application/vnd.msword"
Response.AddHeader "Content-Disposition","attachment;filename="&gxh&".doc"
response.buffer=true
response.expires=0
%>
<%
' 注释:创建并初始化Recordset对象
Set rst = Server.CreateObject("ADODB.Recordset")
rst.ActiveConnection = Conn
rst.Source = "SELECT * FROM 过程卡1 where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'"
rst.CursorType = 3 ' 指针类型为静态指针
rst.Open
if rst.EOF then
response.write("无纪录!")
else
rst.PageSize =1
If Request("DisplayPage") = "" then ' 没有DisplayPage参数
CurPage = 1 ' 定义要显示的页码
Else
CurPage = CInt(Request("DisplayPage"))
End if
For i = 1 to rst.PageSize
If rst.EOF then Exit For ' 没有记录时提前退出
%>

<table width="860" border="1" align="center">
<tr>
<td width="300" rowspan="2"><div align="center" class="STYLE1">工 序 卡 片</div></td>
<td height="20" colspan="2"><div align="center" class="STYLE5 STYLE5">共<% =rst.PageCount %>页</div></td>
<td colspan="2"><div align="center">第 页</div></td>
<%
sql="select * from gckxx where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql,conn
%>
<td width="70"><div align="center" class="STYLE5 STYLE5">产品名称</div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5"><%=RST("cpmc")%></div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5">坯料牌号</div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5"><%=RST("clmchph")%></div></td>
</tr>
<tr>
<%
dim sql1
sql1="select * from 过程卡1 where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'and gxh='"&gxh&"'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql1,conn
%>
<td width="70" height="20"><div align="center" class="STYLE5 STYLE5">零件名称</div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5"><%=RST("ljmc")%></div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5">零件图号</div></td>
<td width="70"><div align="center" class="STYLE5 STYLE5"><%=RST("ljbh")%></div></td>
<td><div align="center" class="STYLE5 STYLE5">单 件</div></td>
<td><div align="center" class="STYLE5 STYLE5"><%=RST("djgsh")%></div></td>
<td><div align="center" class="STYLE5 STYLE5">辅 助</div></td>
<td><div align="center" class="STYLE5 STYLE5"><%=RST("zhjgsh")%></div></td>
</tr>
</table>
<table width="860" border="1" align="center">
<tr>
<td width="90" rowspan="2"><div align="center" class="STYLE3">第<%=RST("gxh")%>道工序</div></td>
<td width="50" rowspan="2"><div align="center" class="STYLE3">机床</div> <div align="center" class="STYLE3">设备</div></td>
<td width="50"><div align="center" class="STYLE3">名称</div></td>
<td width="110"><div align="center" class="STYLE3"><%=RST("jichuang")%></div></td>
<td width="50" rowspan="2"><div align="center" class="STYLE3">夹具</div> <div align="center" class="STYLE3">名称</div></td>
<td width="50"><div align="center" class="STYLE3">名称</div></td>
<td width="110"><div align="center" class="STYLE3"><%=RST("jiaju")%></div></td>
<td width="50"><div align="center" class="STYLE3">工序</div></td>
<td width="300" rowspan="2"><div align="center" class="STYLE3"><%=RST("jgneirong")%></div></td>
</tr>
<tr>
<td><div align="center" class="STYLE3">编号</div></td>
<td><div align="center" class="STYLE3"><%=RST("jichuangdaihao")%></div></td>
<td><div align="center" class="STYLE3">编号</div></td>
<td><div align="center" class="STYLE3"><%=RST("jiajudaihao")%></div></td>
<td><div align="center" class="STYLE3">内容</div></td>
</tr>
</table>

<table width="860" border="1" align="center">
<tr>
<td width="350" rowspan="19"><label><img src="images/<%=RST("tu")%>" width="330" height="400" alt="" /></label></td> 图片显示代码

<td width="30" rowspan="2"><div align="center" class="STYLE4">工</div>
<div align="center" class="STYLE4">步</div></td>
<td width="150" rowspan="2"><div align="center" class="STYLE4">工步内容</div></td>
<td width="110"><div align="center" class="STYLE4">刀 刃 具</div></td>
<td width="110"><div align="center" class="STYLE4">辅  具</div></td>
<td width="110"><div align="center" class="STYLE4">量  具</div></td>
</tr>
<tr>
<td><div align="center" class="STYLE4">名称及编号</div></td>
<td><div align="center" class="STYLE4">名称及编号</div></td>
<td><div align="center" class="STYLE4">名称及编号</div></td>
</tr>
<%
dim sql2
sql1="select * from 工序1 where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'and gxh='"&gxh&"' and gb='1'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql1,conn
if rst.EOF then
%>
<tr>
<%
response.write("【该工序未编!】")
else
%>
<td height="30"><div align="center" class="STYLE4"><%=RST("gb")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("gbneirong")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("daoju")%><%=RST("daojudaihao")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("jiaju")%><%=RST("jiajudaihao")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("liangju")%><%=RST("liangjudaihao")%></div></td>
</tr>
<%
end if
%>
<%
dim sql3
sql1="select * from 工序1 where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'and gxh='"&gxh&"' and gb='2'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql1,conn
if rst.EOF then
%>
<tr>
<td height="30"> </td>
<td height="30"> </td>
<td height="30"> </td>
<td height="30"> </td>
<td height="30"> </td>
</tr>
<%
else
%>
<tr>
<td height="30"><div align="center" class="STYLE4"><%=RST("gb")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("gbneirong")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("daoju")%><%=RST("daojudaihao")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("jiaju")%><%=RST("jiajudaihao")%></div></td>
<td height="30"><div align="center" class="STYLE4"><%=RST("liangju")%><%=RST("liangjudaihao")%></div></td>
<%
end if
%>
</table>
<%
dim sql10
sql10="select * from gckxx where ljbh='" & ljbh & "' and ljmc='"&ljmc&"'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql10,conn
%>
<table width="860" border="1" align="center">
<tr>
<td width="460" rowspan="2"><div align="center" class="STYLE1">工艺设计管理系统</div></td>
<td width="200"><div align="center">编    制</div></td>
<td width="200"><div align="center"><%=RST("shj")%></div></td>
</tr>
<tr>
<td><div align="center">审    核</div></td>
<td width="200"><div align="center"><%=RST("shpy")%></div></td>
</tr>
</table>
<%
dim sql11
sql11="select * from 过程卡1 where ljbh='" & ljbh & "' and ljmc='"&ljmc&"' and gxh='"&gxh&"'"
Set rst= Server.CreateObject("ADODB.Recordset")
rst.open sql11,conn
%>
<p align="center" class="STYLE1"> </p>
<label></label>
<%
rst.MoveNext
Next
end if
%>
<%
rst.Close ' 关闭记录集
Set rst = Nothing
Conn.Close ' 关闭数据库连接
Set Conn = Nothing
%>
</body>
</html>
...全文
172 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
至于数据太多,WORD分页显示的问题,无需操心,WORD自然自己会分页的。

图片的问题,是因为你使用的路径。看看“相对路径”“绝对路径”这种基础知识点就知道了。
你可以尝试一下,把IMAGES图片目录拷贝到WORD文档所在目录里看看行不行。
  • 打赏
  • 举报
回复
你使用分页的话,HTML里本身就只包含数据第一页的内容,当然转换成的WORD也只包含第一页了……

解决方法:
1.直接取消分页,在HTML里返回全部数据并自动转换成WORD。
2.仍要显示第一分页数据给用户看。那就在“转换为WORD”按钮的事件里调用另一个ASP返回数据库全部数据再转换为WORD。此法两下兼得。

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧