技术笔记
一名已转行的程序员ASP输出生成Word 、Excel、Txt文件的方法
2017-02-20 / 代码笔记 / 726 次围观 / 0 次吐槽1、用ASP生成Word文档,代码示例:
<% Response.ContentType = "application/msword" Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc" Response.Write("欢迎来到源码爱好者!<br>" & vbnewline) Response.Write("<h1>用ASP生成Word文档的示例</h1>") response.write "<table width=""100%"" border=""1"" >" response.write "<tr>" response.write "<th width=""40%""><b>Name</b></th>" response.write "<th width=""30%""><b>Username</b></th>" response.write "<th width=""30%""><b>Password</b></th>" response.write "</tr>" response.write "<tr>" response.write "<td width=""40%"">源码爱好者</td>" response.write "<td width=""30%"">user</td>" response.write "<td width=""30%"">mypassword</td>" response.write "</tr>" response.write "</table>" %>
2、ASP生成Excel文档:
<% Response.AddHeader "Content-Disposition", "attachment;filename=members.xls" Response.ContentType = "application/vnd.ms-excel" response.write "<table width=""100%"" border=""1"" >" response.write "<tr>" response.write "<th width=""40%""><b>教程文章</b></th>" response.write "<th width=""30%""><b>Username</b></th>" response.write "<th width=""30%""><b>Password</b></th>" response.write "</tr>" response.write "<tr>" response.write "<td width=""40%"">源码爱好者</td>" response.write "<td width=""30%"">user</td>" response.write "<td width=""30%"">mypassword</td>" response.write "</tr>" response.write "</table>" %>
3、ASP生成Txt文档,这个最简单,用Fso就可以:
<% set objFso = server.createobject("scripting.filesystemobject") set objFile = objFso.CreateTextFile("sample.txt", false) objFile.write "这是一个生成txt文本的演示文档" objFile.close set objFile = nothing objFso = nothing %>
推荐您阅读更多有关于“”的文章
- 上一篇:ASP删除文件夹
- 下一篇:JS判断电脑打开手机站跳转(不允许用电脑访问手机站)
Powered By Z-BlogPHP
Copyright 技术笔记 Rights Reserved.
额 本文暂时没人评论 来添加一个吧
发表评论