Jason ---分享,共同進(jìn)步

          激情成就夢(mèng)想,努力創(chuàng)造未來(lái)
          隨筆 - 53, 文章 - 1, 評(píng)論 - 45, 引用 - 0
          數(shù)據(jù)加載中……

          java web 導(dǎo)出excel

          看到這個(gè)標(biāo)題,會(huì)很疑問(wèn),java導(dǎo)出excel 有很多文章呀,都知道怎么用呀,呵呵,我也是這么認(rèn)為,我們常用的就是jxl 或者poi ,現(xiàn)在jxl 代碼不在更新不支持2007,一般都采用poi 進(jìn)行excel的操作,今天在看系統(tǒng)(架構(gòu)struts+ spring+ hibernate),需要做一個(gè)excel導(dǎo)出,一個(gè)簡(jiǎn)單的方法,這個(gè)方法只適用于excel簡(jiǎn)單的導(dǎo)出,直接通過(guò)輸出的頁(yè)面,然后設(shè)置頁(yè)面為輸出流的文件格式,這樣當(dāng)action轉(zhuǎn)向到j(luò)sp頁(yè)面的時(shí)候,直接就是將頁(yè)面輸出。

           

          jsp頁(yè)面的代碼:

          Java代碼 復(fù)制代碼
          1. <%@ page language="java" pageEncoding="UTF8"%>   
          2. <html:html locale="true">   
          3.     <head>      
          4.         <title>LogExport</title>   
          5.         <meta http-equiv="pragma" content="no-cache">   
          6.         <meta http-equiv="cache-control" content="no-cache">   
          7.         <meta http-equiv="expires" content="0">   
          8.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   
          9.         <%   
          10.           response.setCharacterEncoding("UTF-8");   
          11.           response.setContentType("application/vnd.ms-excel;");      
          12.           response.setHeader("Content-Disposition""attachment;filename=\""+new String("Log.xls".getBytes(),"ISO-8859-1")+"\"");   
          13.         %>     
          14.     </head>   
          15.     <body>   
          16.         <form action="/Action_export.do">   
          17.             <table width="100%" border="1" cellspacing="0" cellpadding="0" id="datagrid">   
          18.                 <thead>   
          19.                     <tr class="HeaderStyle" style="font-weight: normal;">   
          20.                         <th>用戶</th>   
          21.                         <th>姓名</th>   
          22.                         <th>日期</th>   
          23.                         <th>登錄IP</th>   
          24.                         <th>主機(jī)名</th>   
          25.                         <th colspan="3">   
          26.                          <table width='100%'  border="1" cellspacing="3" cellpadding="0" frame='void' >    
          27.                                 <tr><td colspan="3" style='background:transparent;' align="center">操作信息</td></tr>   
          28.                                 <tr style='background:transparent;'>   
          29.                                     <td width="40px" align="center">操作</td>   
          30.                                     <td width="100px" align="center">標(biāo)題</td>   
          31.                                     <td align="center">擴(kuò)展信息</td>   
          32.                                 </tr>   
          33.                             </table>   
          34.                         </th>   
          35.                     </tr>   
          36.                 </thead>   
          37.                 <jsp:include page="common.jsp" flush="true" />   
          38.             </table>   
          39.         </form>   
          40.     </body>   
          41. </html:html>  

          posted on 2012-11-03 12:45 agun 閱讀(2516) 評(píng)論(1)  編輯  收藏 所屬分類: java web

          評(píng)論

          # re: java web 導(dǎo)出excel [未登錄](méi)  回復(fù)  更多評(píng)論   

          123123123123
          2013-05-17 14:53 | 123
          主站蜘蛛池模板: 靖西县| 临城县| 平谷区| 容城县| 尖扎县| 北辰区| 泰安市| 冕宁县| 呼和浩特市| 万源市| 麟游县| 永善县| 龙州县| 迭部县| 潼关县| 会理县| 陇川县| 丰原市| 来凤县| 庐江县| 黑山县| 黑水县| 延寿县| 黄浦区| 黔东| 始兴县| 平湖市| 聂拉木县| 明光市| 措美县| 阿荣旗| 临朐县| 雷州市| 南郑县| 秦皇岛市| 苏州市| 大田县| 永嘉县| 高唐县| 平和县| 榆树市|