不少客户需要网站具备生成成word excel文档 ,使用以下方法能够比较快捷的生成相关文档
-
EXCEL
-
<%
-
Response.ContentType ="application/vnd.ms-excel"
-
Response.AddHeader "Content-Disposition", "attachment; filename=潍坊网站制作报价.xls"
-
%>
-
-
WORD
-
<%
-
Response.ContentType ="application/vnd.ms-word"
-
Response.AddHeader "Content-Disposition", "attachment; filename=潍坊网站制作报价.doc"
-
%>
导出为WORD时,若文档中含有表格,需要打打印,则要在导出的页面中加入下面的样式。
-
<style type="text/css">
-
<!--
-
table{
-
border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
-
mso-yfti-tbllook:480;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:
-
.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext;border-left:solid windowtext 1.0pt;border-top:solid windowtext 1.0pt;
-
}
-
td{
-
border-top:none;border-left:
-
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
-
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
-
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;
-
}
-
-->
-
</style>
我打字系统项目中的一个导出为EXCEL文件的实例代码如下:
-
<!--#include file="hbwlConfig.asp" -->
-
<%Response.ContentType ="application/vnd.ms-excel"
-
Response.AddHeader "Content-Disposition", "attachment; filename=chengji.xls"%>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>潍坊网站制作报价</title>
-
<style type="text/css">
-
.tableWg {border:1px solid #9bbde6;}
-
.tableWg tr{text-align:center;}
-
.tableWg td{ border-bottom:1px dotted #9bbde6; border-right:1px dotted #9bbde6;}
-
</style>
-
</head>
-
<body>
-
<%sql=session("chengjisql")
-
response.Write hbwl.dbSelect(sql,0,1,"",0,"",0,"tableWg")%>
-
</body>
-
</html>
-
<%set hbwl=nothing%>