ASP线上建立Word与Excel文本文档

ASP具有动态性輸出任一Office运用程叙文件文件格式的作用。在刚开始撰写编码以前,大家最先必须做的便是设定恰当的文档种类,由于访问器必须了解怎样解决文档。第二步是编写文档名字,大家可使用HTML和CSS来建立Word文本文档或Excel文本文档的款式。

  下边这一段事例编码能用于线上建立Word文本文档。

下列是引入片断:
%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"??? 
response.Write(" : a href=""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 /td "
response.write " td width=""30%"" mypassword /td "
response.write " /tr "
response.write " /table "
%



扫描二维码分享到微信