<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    陌上花開(kāi)

    遇高山,我御風(fēng)而翔,逢江河,我凌波微波

       :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::

    一,先新建一個(gè)excel文件,調(diào)整格式(就是你所想要顯示的格式),
    二,把剛才新建的excel文件令存為.html(demo.html)文件,
    三,新建一個(gè)jsp頁(yè)面, 在該JSP頁(yè)面頭部設(shè)置response的ContentType為Excel格式
    <% response.setContentType("application/vnd.ms-excel;charset=GBK"); %>
    然后設(shè)置網(wǎng)頁(yè)資料是以excel報(bào)表以線(xiàn)上瀏覽方式呈現(xiàn)或者是下載的方式呈現(xiàn)
    <%
    / /這行設(shè)定傳送到前端瀏覽器時(shí)的檔名為test1.xls  就是靠這一行,讓前端瀏覽器以為接收到一個(gè)excel檔 
     //將網(wǎng)頁(yè)資料以excel報(bào)表以線(xiàn)上瀏覽方式呈現(xiàn)
    response.setHeader("Content-disposition","inline; filename=test1.xls");
       //將網(wǎng)頁(yè)資料以下載的方式
    response.setHeader("Content-disposition","attachment; filename=test2.xls");
    %>
    然后把 demo.html的源代碼粘貼在jsp頁(yè)面,如下

    <%@ page contentType="text/html; charset=GBK" %>
    <% response.setContentType("application/vnd.ms-excel;charset=GBK");
    response.setHeader("Content-disposition","attachment; filename=test2.xls");

    %>
    <!--以下為保持成html頁(yè)面的excel的內(nèi)容 demo.html頁(yè)面-->
    <html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="http://www.w3.org/TR/REC-html40">

    <head>
    <meta http-equiv=Content-Type content="text/html; charset=gb2312">
    <meta name=ProgId content=Excel.Sheet>
    <meta name=Generator content="Microsoft Excel 11">
    <link rel=File-List href="qwe.files/filelist.xml">
    <link rel=Edit-Time-Data href="qwe.files/editdata.mso">
    <link rel=OLE-Object-Data href="qwe.files/oledata.mso">
    <!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Created>1996-12-17T01:32:42Z</o:Created>
      <o:LastSaved>2010-05-12T13:59:04Z</o:LastSaved>
      <o:Version>11.9999</o:Version>
     </o:DocumentProperties>
     <o:OfficeDocumentSettings>
      <o:RemovePersonalInformation/>
     </o:OfficeDocumentSettings>
    </xml><![endif]-->
    <style>
    <!--table
     {mso-displayed-decimal-separator:"\.";
     mso-displayed-thousand-separator:"\,";}
    @page
     {margin:1.0in .75in 1.0in .75in;
     mso-header-margin:.5in;
     mso-footer-margin:.5in;}
    tr
     {mso-height-source:auto;
     mso-ruby-visibility:none;}
    col
     {mso-width-source:auto;
     mso-ruby-visibility:none;}
    br
     {mso-data-placement:same-cell;}
    .style0
     {mso-number-format:General;
     text-align:general;
     vertical-align:bottom;
     white-space:nowrap;
     mso-rotate:0;
     mso-background-source:auto;
     mso-pattern:auto;
     color:windowtext;
     font-size:12.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     border:none;
     mso-protection:locked visible;
     mso-style-name:常規(guī);
     mso-style-id:0;}
    td
     {mso-style-parent:style0;
     padding-top:1px;
     padding-right:1px;
     padding-left:1px;
     mso-ignore:padding;
     color:windowtext;
     font-size:12.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     mso-number-format:General;
     text-align:general;
     vertical-align:bottom;
     border:none;
     mso-background-source:auto;
     mso-pattern:auto;
     mso-protection:locked visible;
     white-space:nowrap;
     mso-rotate:0;}
    ruby
     {ruby-align:left;}
    rt
     {color:windowtext;
     font-size:9.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     mso-char-type:none;
     display:none;}
    -->
    </style>
    <!--[if gte mso 9]><xml>
     <x:ExcelWorkbook>
      <x:ExcelWorksheets>
       <x:ExcelWorksheet>
        <x:Name>Sheet1</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet1</x:CodeName>
         <x:Selected/>
         <x:Panes>
          <x:Pane>
           <x:Number>3</x:Number>
           <x:ActiveCol>1</x:ActiveCol>
          </x:Pane>
         </x:Panes>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
       <x:ExcelWorksheet>
        <x:Name>Sheet2</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet2</x:CodeName>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
       <x:ExcelWorksheet>
        <x:Name>Sheet3</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet3</x:CodeName>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
      </x:ExcelWorksheets>
      <x:WindowHeight>4530</x:WindowHeight>
      <x:WindowWidth>8505</x:WindowWidth>
      <x:WindowTopX>480</x:WindowTopX>
      <x:WindowTopY>120</x:WindowTopY>
      <x:AcceptLabelsInFormulas/>
      <x:ProtectStructure>False</x:ProtectStructure>
      <x:ProtectWindows>False</x:ProtectWindows>
     </x:ExcelWorkbook>
    </xml><![endif]-->
    </head>

    <body link=blue vlink=purple>

    <table x:str border=0 cellpadding=0 cellspacing=0 width=288 style='border-collapse:
     collapse;table-layout:fixed;width:216pt'>
     <col width=72 span=4 style='width:54pt'>
     <tr height=19 style='height:14.25pt'>
      <td height=19 width=72 style='height:14.25pt;width:54pt'>全球</td>
      <td width=72 style='width:54pt'>問(wèn)問(wèn)</td>
      <td width=72 style='width:54pt'>ee</td>
      <td width=72 style='width:54pt'>rr</td>
     </tr>
     <tr height=19 style='height:14.25pt'>
      <td height=19 style='height:14.25pt'>暗暗</td>
      <td>ss</td>
      <td>dd</td>
      <td>ff</td>
     </tr>
     <![if supportMisalignedColumns]>
     <tr height=0 style='display:none'>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
     </tr>
     <![endif]>
    </table>

    </body>

    </html>


    中文問(wèn)題:
    查看源代碼時(shí)發(fā)現(xiàn)JSP文件中寫(xiě)死的中文為亂碼,則在JSP文件頭部添加一行
    <%@ page contentType="text/html; charset=gb2312" %>
    查看源代碼時(shí)發(fā)現(xiàn)文字為中文,但是用Excel打開(kāi)為亂碼則在<html>與<head>中加入
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">

    在jsp頁(yè)面中,要在excel中顯示的內(nèi)容可以從數(shù)據(jù)庫(kù)中讀取,在此就不做詳細(xì)的介紹了

    posted on 2010-05-12 22:06 askzs 閱讀(4740) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): java
    我要啦免费统计
    主站蜘蛛池模板: 亚洲精品偷拍无码不卡av| 亚洲另类无码专区丝袜| 91麻豆最新在线人成免费观看| 亚洲性线免费观看视频成熟| 国产伦一区二区三区免费| 日韩免费高清播放器| 亚洲国产成人久久综合一区| 亚洲成av人在片观看| 99视频免费观看| 男男黄GAY片免费网站WWW| 7777久久亚洲中文字幕蜜桃| 免费中文字幕在线观看| 日韩免费无码一区二区三区| 立即播放免费毛片一级| 亚洲欧洲视频在线观看| 亚洲国产精品无码久久青草| 麻豆视频免费播放| 国产伦精品一区二区免费| 涩涩色中文综合亚洲| 亚洲av无码精品网站| 免费国产在线观看不卡| 免费AA片少妇人AA片直播| 国产免费人成视频尤勿视频| 中文字幕无码精品亚洲资源网久久| 精品久久香蕉国产线看观看亚洲| 成年女人免费碰碰视频| 国内精品久久久久影院免费| 亚洲av成人中文无码专区| 亚洲第一二三四区| 亚洲精品自在在线观看| 天堂亚洲免费视频| 全免费一级午夜毛片| 很黄很色很刺激的视频免费| 午夜精品免费在线观看| 亚洲精品偷拍视频免费观看| 色噜噜噜噜亚洲第一| 亚洲乱码在线观看| 亚洲第一页中文字幕| 亚洲欧洲免费视频| 久久久久久a亚洲欧洲aⅴ| 亚洲免费一区二区|