首页 » 网络编程 » :技巧:用ASP在线创建Word与Excel文档
« 电脑无法启动故障的10种解决方法Office快捷键:用于Excel表格的快捷键 »

技巧:用ASP在线创建Word与Excel文档

ASP具备动态输出任一Office应用程序文件格式的功能。在开始编写代码之前,我们首先需要做的就是设置正确的文件类型,因为浏览器需要知道如何处理文件。第二步是编辑文件名称,我们可以使用HTML和CSS来创建Word文档或Excel文档的样式。

     下面这段例子代码可用于在线创建Word文档。

以下是引用片段:
<%
Response.ContentType = "application/msWord"
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"??? 
response.Write("Dotnetindex.com : <a href=""http://www.dotnetindex.com"">Visit Site</a><br>" & vbnewline)
response.Write("<h1>We can use HTML codes for Word documents</h1>")
response.Write ("<div style=""padding:4px; font:11px arial"">CSS can be used tooo</span>")
%>

     下面这段例子代码可用于在线创建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>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%"">Scud Block</td>"
response.write "<td width=""30%"">scud@gazatem.com</td>"
response.write "<td width=""30%"">mypassWord</td>"
response.write "</tr>"
response.write "</table>"
%>

 

  • 收藏到网摘:
  • 免责声明:本站信息来源于互联网、期刊杂志或由作者提供,其内容并不代表本网观点,仅供参考。如有侵犯您的版权或其他有损您利益的行为,请联系我们,我们会立即进行查证并删除相关内容
  • 相关文章

发表评论

为了防止SPAM,含链接的评论需要审核后才能显示。

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

发布商链接


最近发表

发布商链接