熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

用ASP在線創建Word與Excel文檔

2022-06-13   來源: .NET編程 

  ASP具備動態輸出任一Office應用程序文件格式的功能在開始編寫代碼之前我們首先需要做的就是設置正確的文件類型因為浏覽器需要知道如何處理文件第二步是編輯文件名稱我們可以使用HTML和CSS來創建Word文檔或Excel文檔的樣式
 
  下面這段例子代碼可用於在線創建Word文檔

  以下是引用片段

<%
ResponseContentType = application/msword
ResponseAddHeader ContentDisposition attachment;filename=NAMEdoc??? 
responseWrite(Dotnetindexcom : <a href=visit/>http://wwwdotnetindexcom>Visit Site</a><br> & vbnewline)
responseWrite(<h>We can use HTML codes for word documents</h>)
responseWrite (<div style=padding:px; font:px arial>CSS can be used tooo</span>)
%>

  下面這段例子代碼可用於在線創建Excel文檔

   以下是引用片段

BORDERRIGHT: #cccccc px solid; PADDINGRIGHT: px; BORDERTOP: #cccccc px solid; PADDINGLEFT: px; BACKGROUND: #fff; PADDINGBOTTOM: px; MARGIN: px px; BORDERLEFT: #cccccc px solid; PADDINGTOP: px; BORDERBOTTOM: #cccccc px solid><%
ResponseAddHeader ContentDisposition attachment;filename=membersxls
ResponseContentType = application/vndmsexcel
responsewrite <table width=% border= >
responsewrite <tr>
responsewrite <th width=%><b>Name</b></th>
responsewrite <th width=%><b>Username</b></th>
responsewrite <th width=%><b>Password</b></th>
responsewrite </tr>
responsewrite <tr>
responsewrite <td width=%>Scud Block</td>
responsewrite <td width=%>scud@gazatemcom</td>
responsewrite <td width=%>mypassword</td>
responsewrite </tr>
responsewrite </table>
%>
From:http://tw.wingwit.com/Article/program/net/201311/14969.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.