请各位老大指导一下:
我想实现在JSP中查询完数据后调用EXCEL显示在客户端,而不是直接以网页中表格的格式显示!多谢!如果分数不够我可以另外在给!

解决方案 »

  1.   

    可能用tomcat版本有些老吧?4。0的?
    你在tomcat/conf/web.xml  中加上下面那段试试
      
      <mime-mapping>
            <extension>xsl</extension>
            <mime-type>text/xml</mime-type>
        </mime-mapping>
      

  2.   

    <mime-mapping> 
    <extension>xls</extension> 
    <mime-type>application/vnd.ms-excel
    </mime-type>
    </mime-mapping>sorry 应该是这句
      

  3.   

    <%@ page contentType="application/vnd.ms-excel;charset=GBK" %>
    <%@ page language="java"%>
    <%@ page import="wuye.database.*,java.sql.*,wuye.util.*" %>
    <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 9">
    <link rel=File-List href="./roominfor.files/filelist.xml">
    <link rel=Edit-Time-Data href="./roominfor.files/editdata.mso">
    <link rel=OLE-Object-Data href="./roominfor.files/oledata.mso">
    <title>房间信息表</title>
    <!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Author>chenansheng</o:Author>
      <o:LastAuthor>chenansheng</o:LastAuthor>
      <o:Created>2004-03-24T10:42:08Z</o:Created>
      <o:LastSaved>2004-03-24T11:08:51Z</o:LastSaved>
      <o:Company>agrs</o:Company>
      <o:Version>9.2812</o:Version>
     </o:DocumentProperties>
     <o:OfficeDocumentSettings>
      <o:DownloadComponents/>
      <o:LocationOfComponents HRef="file:///F:/msowc.cab"/>
     </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;}
    .font0
    {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;}
    .font6
    {color:windowtext;
    font-size:12.0pt;
    font-weight:400;
    font-style:normal;
    text-decoration:none;
    font-family:"Times New Roman", serif;
    mso-font-charset:0;}
    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:常规;
    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:Print>
          <x:ValidPrinterInfo/>
          <x:PaperSizeIndex>9</x:PaperSizeIndex>
          <x:HorizontalResolution>600</x:HorizontalResolution>
          <x:VerticalResolution>600</x:VerticalResolution>
         </x:Print>
         <x:Selected/>
         <x:Panes>
          <x:Pane>
           <x:Number>3</x:Number>
           <x:ActiveRow>2</x:ActiveRow>
           <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:Panes>
          <x:Pane>
           <x:Number>3</x:Number>
           <x:ActiveCol>1</x:ActiveCol>
           <x:RangeSelection>B:B</x:RangeSelection>
          </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>Sheet3</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
      </x:ExcelWorksheets>
      <x:WindowHeight>9225</x:WindowHeight>
      <x:WindowWidth>14940</x:WindowWidth>
      <x:WindowTopX>240</x:WindowTopX>
      <x:WindowTopY>120</x:WindowTopY>
      <x:ProtectStructure>False</x:ProtectStructure>
      <x:ProtectWindows>False</x:ProtectWindows>
     </x:ExcelWorkbook>
    </xml><![endif]-->
    </head>