首页 > 代码库 > jsp导出到Excel
jsp导出到Excel
jsp模板文件
<%@ page isELIgnored="false" contentType="application/x-msdownload; charset=GBK"%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <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"> <%@ taglib uri="/WEB-INF/sino-tags.tld" prefix="sino"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el"%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el"%> <% int i = 0; String tableTitle = "第三方巡查数据导出"; String filename = new String((tableTitle).getBytes("GBK"), "ISO-8859-1") + ".xls"; response.setHeader("Content-Disposition", "attachment;filename=" + filename); %> <head> <meta http-equiv="Content-Type" content="application/x-msexcel;charset=gb2312"> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"> <link rel=File-List href="Book1.files/filelist.xml"> <link rel=Edit-Time-Data href="Book1.files/editdata.mso"> <link rel=OLE-Object-Data href="Book1.files/oledata.mso"> <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; } .xl29 { mso-style-parent: style0; font-size: 17.0pt; font-weight: 700; text-align: center; mso-pattern: auto none; background: #DDDDDD; } --> </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:Selected/> <x:Panes> <x:Pane> <x:Number>3</x:Number> <x:ActiveRow>10</x:ActiveRow> <x:ActiveCol>3</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: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>8445</x:WindowHeight> <x:WindowWidth>11715</x:WindowWidth> <x:WindowTopX>240</x:WindowTopX> <x:WindowTopY>15</x:WindowTopY> <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=551 style=‘table-layout: fixed; width: 680pt; border: 0px solid #000000;‘> <tr height=19 style=‘height: 14.25pt;border: 0px;‘> <td align="center" colspan=‘8‘ > <b>第三方巡查数据导出</b> </td> </tr> <tr height=19 style=‘height: 14.25pt;border: 0px;‘> <td align="left" colspan=‘8‘ > </td> </tr> <tr height=19 style=‘height: 14.25pt;border: 0px;‘> <td align="left" colspan=‘5‘> </td> <td align="left" colspan=‘3‘> </td> </tr> </table> <table x:str border=1 cellpadding=0 cellspacing=0 width=551 style=‘table-layout: fixed; width: 680pt; border: 1px solid #000000;‘> <col width=30 style=‘mso-width-source: userset; mso-width-alt: 2784; width: 30pt‘> <col width=30 style=‘mso-width-source: userset; mso-width-alt: 5120; width: 30pt‘> <col width=30 style=‘mso-width-source: userset; mso-width-alt: 5120; width: 30pt‘> <col width=150 style=‘mso-width-source: userset; mso-width-alt: 4000; width: 150pt‘> <col width=30 style=‘mso-width-source: userset; mso-width-alt: 5728; width: 60pt‘> <col width=60 style=‘mso-width-source: userset; mso-width-alt: 2784; width: 60pt‘> <col width=300 style=‘mso-width-source: userset; mso-width-alt: 5120; width: 300pt‘> <tr height=19 style=‘height: 14.25pt;‘> <td width=30 style=‘text-align:center‘> 序号 </td> <td width=30 style=‘text-align:center‘> 线路 </td> <td width=30 style=‘text-align:center‘> 单位工程 </td> <td width=150 style=‘text-align:center‘> 标题 </td> <td width=60 style=‘text-align:center‘> 巡查单位 </td> <td width=60 style=‘text-align:center‘> 巡查时间 </td> <td width=60 style=‘text-align:center‘> 巡查结果 </td> <td width=60 style=‘text-align:center‘> 是否预警 </td> <td width=300 style=‘text-align:center‘> 预警等级 </td> </tr> <s:if test="#request.list.size!=0"> <s:iterator value="#request.list" id="obj" status="index" > <tr height=19 style=‘height: 14.25pt;‘> <td height="22" align="center" onClick=""> <s:property value=‘#index.index+1‘/> </td> <td height="22" align="left"> <s:property value=‘lineName‘ /> </td> <td height="22" align="center"> <s:property value=‘alias‘ /> </td> <td height="22" align="center"> <s:property value=‘title‘ /> </td> <td height="22" align="center"> <s:property value=‘companyName‘ /> </td> <td height="22" align="center"> <s:property value=‘patrolTimeStr‘ /> </td> <td height="22" align="center"> <s:property value=‘patrolResult‘ /> </td> <td height="22" align="center"> <s:property value=‘isAlarm‘ /> </td> <td height="22" align="left" > <s:property value=‘warningLevel‘ /> </td> </tr> </s:iterator> </s:if> <s:if test="#request.list.size==0"> <tr> <td colspan="9">未找到任何数据</td> </tr> </s:if> </table> </body> </html>
jsp导出到Excel
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。