象寫頁面一樣生成“導出EXCEL和WORD” ,中間嵌入JAVA代碼就可以。 不用第3方的開發(fā)包,比如 jxl.jar包。 保存的名字默認是當前頁面的名字。 最重要是加了代碼:
- <%@ page contentType="application/msword;charset=UTF-8" %>
- <%@ page contentType="application/vnd.ms-excel;charset=UTF-8" %>
word:
-
- <%@ page contentType="application/msword;charset=GBK" %>
- <%@ page language="java" %>
- <html>
- <head>
- <title>word列表</title>
- <meta Content-Disposition="attachment; filename=a.doc">
- </head>
- <body>
- <table width="600" border="1" cellspacing="0" cellpading="0">
- <tr>
- <td align="center" colspan="4" ><strong><font color="red">生成的考核結(jié)果</font></strong></td>
- </tr>
- <tr>
- <td align="center" >考評對象</td>
- <td align="center">考核總分</td>
- <td align="center">排名</td>
- </tr>
- <tr>
- <td align="center"> </td>
- <td align="center"></td>
- <td align="center"></td>
- </tr>
- </table>
- </body>
- </html>
excel:
xml 代碼
- <%@ page contentType="application/vnd.ms-excel;charset=GBK" %>
- <%@ page language="java" %>
- <html>
- <head>
- <title>excel列表</title>
- <meta Content-Disposition="attachment; filename=a.xls">
- </head>
- <body>
- <table width="600" border="1" cellspacing="0" cellpading="0">
- <tr>
- <td align="center" colspan="4" ><strong><font color="red">生成的考核結(jié)果</font></strong></td>
- </tr>
- <tr>
- <td align="center" >考評對象</td>
- <td align="center">考核總分</td>
- <td align="center">排名</td>
- </tr>
- <tr>
- <td align="center"> </td>
- <td align="center"></td>
- <td align="center"></td>
- </tr>
- </table>
- </body>
- </html>
|