WORDResponse.ContentType="application/vnd.ms-word"Response.AddHeader"Content-Dis" />

ASP导出为Word或Excel的最简单方法

Asp代码
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时,若文档中含有表格,需要打打印,则要在导出的页面中加入下面的样式。

Css代码




系统项目中的一个导出为EXCEL文件的实例代码如下:

Asp代码

<%Response.ContentType ="application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=chengji.xls"%>




成绩



<%sql=session("chengjisql")
response.Write hbwl.dbSelect(sql,0,1,"",0,"",0,"tableWg")%>


<%set hbwl=nothing%>

相关文档
最新文档