- <%@ page contentType="application/msexcel" %>
- <%
- //獨立開啟excel軟體
- response.setHeader("Content-disposition","attachment; filename=MyExcel.xls");
-
- //嵌套在ie裡開啟excel
-
- //response.setHeader("Content-disposition","inline; filename=MyExcel.xls");
-
- //Word只需要把contentType="application/msexcel"改為contentType="application/msword"
- %>
- <html>
- <head>
- <title>測試匯出Excel和Word</title>
- </head>
- <body>
- <table width="500" border="1" align="center">
- <tr>
- <td colspan="4" align="center">電子產品測試統計</td>
- </tr>
- <tr>
- <td width="7%">條碼</td>
- <td width="7%">電壓</td>
- <td width="18%">電流</td>
- <td width="68%">功率</td>
- </tr>
- <tr>
- <td>20061006</td>
- <td>xxx</td>
- <td>xxx</td>
- <td>xxxxx</td>
- </tr>
- <tr>
- <td>20061007</td>
- <td>xx</td>
- <td>xxx</td>
- <td>xxxxx</td>
- </tr>
- <tr>
- <td>20061008</td>
- <td>xx</td>
- <td>xxx</td>
- <td>xxxxx</td>
- </tr>
- </table>
- </body>
- </html>
參考網頁:http://www.javaeye.com/topic/375929
類似網頁:http://www.javaeye.com/topic/94817
http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/
Struts2利用stream直接輸出Excel: http://www.java3z.com/cwbwebhome/article/article2/21102.html?id=1890