- 浏览: 6556 次
- 性别:
- 来自: 北京
最新评论
<%@ page language="java" import="java.sql.ResultSet" pageEncoding="UTF-8"%>
<jsp:useBean id="dbBean" class="com.study.ding.wenjuan.Manage_db"
scope="page"></jsp:useBean>
<%
request.setCharacterEncoding("UTF-8");
if(request.getParameter("companyName")!=null)
{
String compayName=request.getParameter("companyName").toString();
ResultSet rs1 = dbBean.getCompany1(compayName);
ResultSet rs2 = dbBean.getCompany2(compayName);
response.reset();
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Content-Disposition" ,"attachment;filename=other.xls");
%>
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>HPO</Author>
<LastAuthor>HPO</LastAuthor>
<LastPrinted>2010-10-26T01:30:00Z</LastPrinted>
<Created>2010-07-28T09:26:51Z</Created>
<LastSaved>2011-02-10T02:40:27Z</LastSaved>
<Company>哈佛企管</Company>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>8895</WindowHeight>
<WindowWidth>14955</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>105</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="新細明體" x:CharSet="136" x:Family="Roman" ss:Size="12"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Font ss:FontName="新細明體" x:CharSet="136" x:Family="Roman" ss:Size="12"
ss:Bold="1"/>
<Interior/>
</Style>
<Style ss:ID="s22">
<Interior/>
</Style>
<Style ss:ID="s23">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s24">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
</Styles>
<Worksheet ss:Name="self">
<Names>
<NamedRange ss:Name="_FilterDatabase" ss:RefersTo="=self!R1C1:R1C25"
ss:Hidden="1"/>
</Names>
<Table ss:ExpandedColumnCount="25" ss:ExpandedRowCount="5" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s22" ss:DefaultColumnWidth="54"
ss:DefaultRowHeight="16.5">
<Column ss:Index="4" ss:StyleID="s22" ss:Width="63"/>
<Column ss:Index="25" ss:StyleID="s22" ss:Width="79.5"/>
<Row ss:Height="33">
<Cell ss:StyleID="s21"><Data ss:Type="String">ID</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">EMAIL</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">TEST_DATE</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A2</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A3</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A4</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A5</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A6</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A7</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A8</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A9</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A10</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A11</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A12</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A13</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A14</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A15</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A16</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A17</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A18</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A19</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A20</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">COMPANY</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
</Row>
<% while (rs2.next()){ %>
<Row ss:Height="33">
<Cell ss:StyleID="s23"><Data ss:Type="Number"><%=rs2.getString("Id") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Name") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Email") %></Data></Cell>
<Cell ss:StyleID="s24"><Data ss:Type="DateTime"><%=rs2.getString("TEST_DATE") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A2") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A3") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A4") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A5") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A6") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A7") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A8") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A9") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A10") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A11") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A12") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A13") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A14") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A15") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A16") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A17") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A18") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A19") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A20") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Company") %></Data></Cell>
</Row>
<% }%>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>0</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="other">
<Names>
<NamedRange ss:Name="_FilterDatabase" ss:RefersTo="=other!R1C1:R1C26"
ss:Hidden="1"/>
</Names>
<Table ss:ExpandedColumnCount="26" ss:ExpandedRowCount="4" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s22" ss:DefaultColumnWidth="54"
ss:DefaultRowHeight="16.5">
<Row ss:Height="33">
<Cell ss:StyleID="s21"><Data ss:Type="String">ID</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">COMPANY</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">EMAIL</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A2</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A3</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A4</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A5</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A6</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A7</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A8</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A9</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A10</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A11</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A12</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A13</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A14</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A15</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A16</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A17</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A18</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A19</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A20</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">TEST_DATE</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
</Row>
<% while (rs1.next()){ %>
<Row ss:Height="49.5">
<Cell ss:StyleID="s23"><Data ss:Type="Number"><%=rs1.getString("Id") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Company") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Name") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Email") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Name1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q2") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q3") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q4") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q5") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q6") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q7") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q8") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q9") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q10") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q11") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q12") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q13") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q14") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q15") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q16") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q17") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q18") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q19") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q20") %></Data></Cell>
<Cell ss:StyleID="s24"><Data ss:Type="String"><%=rs1.getString("TEST_DATE") %></Data></Cell>
</Row>
<%} %>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>0</VerticalResolution>
</Print>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
<AutoFilter x:Range="R1C1:R1C26"
xmlns="urn:schemas-microsoft-com:office:excel">
</AutoFilter>
<Sorting xmlns="urn:schemas-microsoft-com:office:excel">
<Sort>HPO</Sort>
</Sorting>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="16.5">
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
<%}else{
out.println("<script type=\"text/javascript\">alert(\"错误!\");window.close(); </script>");
} %>
总结:
用现有Excel模版 保存成XML形式, JSP页面中 以XML内容输入,以XLS格式输出到客户到保存。
这样可以实现多个sheet,
基本都是XML 的操作。
Excel 长ID会用科学计数法显示。
<jsp:useBean id="dbBean" class="com.study.ding.wenjuan.Manage_db"
scope="page"></jsp:useBean>
<%
request.setCharacterEncoding("UTF-8");
if(request.getParameter("companyName")!=null)
{
String compayName=request.getParameter("companyName").toString();
ResultSet rs1 = dbBean.getCompany1(compayName);
ResultSet rs2 = dbBean.getCompany2(compayName);
response.reset();
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Content-Disposition" ,"attachment;filename=other.xls");
%>
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>HPO</Author>
<LastAuthor>HPO</LastAuthor>
<LastPrinted>2010-10-26T01:30:00Z</LastPrinted>
<Created>2010-07-28T09:26:51Z</Created>
<LastSaved>2011-02-10T02:40:27Z</LastSaved>
<Company>哈佛企管</Company>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>8895</WindowHeight>
<WindowWidth>14955</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>105</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="新細明體" x:CharSet="136" x:Family="Roman" ss:Size="12"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Font ss:FontName="新細明體" x:CharSet="136" x:Family="Roman" ss:Size="12"
ss:Bold="1"/>
<Interior/>
</Style>
<Style ss:ID="s22">
<Interior/>
</Style>
<Style ss:ID="s23">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s24">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"
ss:Color="#000000"/>
</Borders>
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
</Styles>
<Worksheet ss:Name="self">
<Names>
<NamedRange ss:Name="_FilterDatabase" ss:RefersTo="=self!R1C1:R1C25"
ss:Hidden="1"/>
</Names>
<Table ss:ExpandedColumnCount="25" ss:ExpandedRowCount="5" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s22" ss:DefaultColumnWidth="54"
ss:DefaultRowHeight="16.5">
<Column ss:Index="4" ss:StyleID="s22" ss:Width="63"/>
<Column ss:Index="25" ss:StyleID="s22" ss:Width="79.5"/>
<Row ss:Height="33">
<Cell ss:StyleID="s21"><Data ss:Type="String">ID</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">EMAIL</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">TEST_DATE</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A2</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A3</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A4</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A5</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A6</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A7</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A8</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A9</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A10</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A11</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A12</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A13</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A14</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A15</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A16</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A17</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A18</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A19</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A20</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">COMPANY</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
</Row>
<% while (rs2.next()){ %>
<Row ss:Height="33">
<Cell ss:StyleID="s23"><Data ss:Type="Number"><%=rs2.getString("Id") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Name") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Email") %></Data></Cell>
<Cell ss:StyleID="s24"><Data ss:Type="DateTime"><%=rs2.getString("TEST_DATE") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A2") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A3") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A4") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A5") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A6") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A7") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A8") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A9") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A10") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A11") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A12") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A13") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A14") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A15") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A16") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A17") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A18") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A19") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("A20") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs2.getString("Company") %></Data></Cell>
</Row>
<% }%>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>0</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="other">
<Names>
<NamedRange ss:Name="_FilterDatabase" ss:RefersTo="=other!R1C1:R1C26"
ss:Hidden="1"/>
</Names>
<Table ss:ExpandedColumnCount="26" ss:ExpandedRowCount="4" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s22" ss:DefaultColumnWidth="54"
ss:DefaultRowHeight="16.5">
<Row ss:Height="33">
<Cell ss:StyleID="s21"><Data ss:Type="String">ID</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">COMPANY</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">EMAIL</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">NAME1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A1</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A2</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A3</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A4</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A5</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A6</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A7</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A8</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A9</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A10</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A11</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A12</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A13</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A14</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A15</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A16</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A17</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A18</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A19</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">A20</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">TEST_DATE</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
</Row>
<% while (rs1.next()){ %>
<Row ss:Height="49.5">
<Cell ss:StyleID="s23"><Data ss:Type="Number"><%=rs1.getString("Id") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Company") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Name") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Email") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Name1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q1") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q2") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q3") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q4") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q5") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q6") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q7") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q8") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q9") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q10") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q11") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q12") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q13") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q14") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q15") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q16") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q17") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q18") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q19") %></Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String"><%=rs1.getString("Q20") %></Data></Cell>
<Cell ss:StyleID="s24"><Data ss:Type="String"><%=rs1.getString("TEST_DATE") %></Data></Cell>
</Row>
<%} %>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>0</VerticalResolution>
</Print>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
<AutoFilter x:Range="R1C1:R1C26"
xmlns="urn:schemas-microsoft-com:office:excel">
</AutoFilter>
<Sorting xmlns="urn:schemas-microsoft-com:office:excel">
<Sort>HPO</Sort>
</Sorting>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="16.5">
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
<%}else{
out.println("<script type=\"text/javascript\">alert(\"错误!\");window.close(); </script>");
} %>
总结:
用现有Excel模版 保存成XML形式, JSP页面中 以XML内容输入,以XLS格式输出到客户到保存。
这样可以实现多个sheet,
基本都是XML 的操作。
Excel 长ID会用科学计数法显示。
相关推荐
本文将详细介绍如何利用JSP技术实现Excel导出功能,并特别关注如何支持多Sheet导出。 #### 技术栈及工具 本示例中使用的主要是Apache POI库来处理Excel文件。Apache POI是一个流行的Java API,用于读写Microsoft ...
为了解决这个问题,可以采取分sheet导出的方法,将大量数据分割成多个工作表,以提高用户体验和性能。 本实例提供的`exportToExcel()`方法展示了如何在JSP中实现这个功能。首先,通过`systemConfigService....
3. **创建工作表**:接下来,为工作簿创建一个或多个工作表,每个工作表代表Excel的一个sheet。 ```java Sheet sheet = workbook.createSheet("数据表"); ``` 4. **填充数据**:使用`Row`和`Cell`对象向工作表中...
2. **创建Excel工作簿**:使用`XSSFWorkbook`类创建一个新的Excel工作簿对象,它是HSSFWorkbook的升级版,支持更多的Excel功能。 3. **添加工作表**:通过`createSheet()`方法创建新的工作表,并设置工作表的名称。...
在IT领域,特别是Web开发中,JSP(JavaServer Pages)...在JSP中导入导出Excel文件,Apache POI是一个强大且灵活的工具。掌握其基本用法后,可以高效地处理各种Excel文件相关的任务,从而提升Web应用的数据处理能力。
本主题聚焦于"JSP中table导出多表头excel"的技术实现,这是一种常见的需求,特别是在展示复杂表格数据时,多表头能够清晰地组织和展示信息。我们将探讨如何利用前台JavaScript技术来完成这一任务,并关注IE浏览器的...
在Java编程环境中,将JSP表格中的数据导出到Excel文件是一种常见的需求,尤其是在数据分析、报表生成和数据交换等场景中。本篇文章将详细介绍如何利用Java实现这一功能,主要涉及的技术包括Java Servlet、JSP以及...
在JSP中导出Excel,通常我们会用到Apache POI库,这是一个强大的API,用于读写Microsoft Office格式的文件,包括Excel。下面是一个简单的步骤来实现这个功能: 1. **引入Apache POI库**:在项目中添加Apache POI的...
1. **读取Excel文件**:支持从Excel 95、97、2000等多个版本的文件中读取数据。 2. **读取Excel公式**:可以读取Excel 97及之后版本的公式。 3. **生成Excel文件**:可以创建格式为Excel 97的新文件。 4. **格式化...
2. **访问Sheet**:Workbook对象包含了一个或多个Sheet,你可以通过索引或名称访问它们。例如,获取第一个Sheet: ```java Sheet rs = rwb.getSheet(0); ``` 3. **访问Cell**:Sheet包含了许多Cell,你可以获取...
每个Workbook可以有多个Sheet。 ```java XSSFSheet sheet = workbook.createSheet("数据表"); ``` 3. **创建Row对象**:这是Excel中的行。 ```java XSSFRow headerRow = sheet.createRow(0); ``` 4. **...
综上所述,JSP操作Excel并将其数据导入Oracle数据库的过程涵盖了文件读取、数据处理、数据库连接和数据持久化等多个方面。这不仅要求开发者熟悉Java语言的基本操作,还需要掌握Apache POI库的使用以及Oracle数据库的...
在JSP中导出Excel文件是一项常见的需求,例如在报表生成、数据分析等场景。下面将详细介绍JSP如何实现这一功能,以及涉及到的关键技术点。 首先,JSP(JavaServer Pages)是Java的一种视图技术,它允许开发人员在...
在Spring Boot应用中,我们可以将这个方法封装成一个Controller的接口,然后通过JSP页面上传Excel文件,调用这个接口进行解析。以下是一个简单的Controller示例: ```java import org.springframework.web.bind....
在Java Web开发中,JSP...jxl提供了更多的操作Excel的选项,而fastexcel则以其简洁的API和高效的事件驱动读取方式吸引开发者。在实际开发中,还需要注意处理可能出现的异常,确保资源的正确关闭,以避免内存泄漏。
这个名为 "jspexcel" 的压缩包应该包含了上述代码的 JSP 文件和必要的 POI 库,下载后可以直接运行,以了解其工作原理。对于初学者来说,这是一个很好的起点,可以在此基础上进行扩展,满足更复杂的 Excel 生成需求...
4. **创建工作表**:`Workbook`可以包含多个`Sheet`,每个`Sheet`代表Excel中的一个工作表。通过调用`Workbook`的`createSheet`方法,我们可以创建新的工作表。 5. **写入数据**:在工作表上写入数据,可以使用`...
本教程将详细介绍如何使用JAVA POI库来创建一个包含图片的完整Excel导出功能。 首先,你需要在项目中引入Apache POI依赖。如果你使用的是Maven,可以在pom.xml文件中添加以下依赖: ```xml <groupId>org.apache....