标签:excel报表 freemarker 报表导出 报表
如下为个人写的FreeMarker的Excel导出模板实例,用于导出数据到Excel文件中,文件以.flt为扩张名
<?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>wpy</Author> <LastAuthor>wpy</LastAuthor> <Created>2015-04-10T18:30:22Z</Created> <Version>1.00</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <AllowPNG/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>10005</WindowHeight> <WindowWidth>10005</WindowWidth> <WindowTopX>120</WindowTopX> <WindowTopY>135</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Horizontal="Center" ss:Vertical="Center"/> <Borders/> <Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000"/> <Interior/> <NumberFormat/> <Protection/> </Style> <Style ss:ID="header"> <Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#FFFFFF" ss:Bold="1"/> <Interior ss:Color="#000000" ss:Pattern="Solid"/> </Style> <Style ss:ID="content"> <Borders> <Border ss:Position="Bottom" ss:LineStyle="Dot" ss:Weight="1"/> <Border ss:Position="Left" ss:LineStyle="Dot" ss:Weight="1"/> <Border ss:Position="Right" ss:LineStyle="Dot" ss:Weight="1"/> <Border ss:Position="Top" ss:LineStyle="Dot" ss:Weight="1"/> </Borders> <Interior ss:Color="#EEECE1" ss:Pattern="Solid"/> </Style> </Styles> <#if (serversPayExpendList?size==0)> <Worksheet ss:Name="${reportName!}"> <Table> <Column ss:AutoFitWidth="0" ss:Width="100"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="header"><Data ss:Type="String">编号</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">服务器名</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">充值元宝汇总</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">消费元宝汇总</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">剩余元宝汇总</Data></Cell> </Row> </Table> </Worksheet> </#if> <#list serversPayExpendList as serversPayExpend> <#if (serversPayExpend_index%50000==0)> <Worksheet ss:Name="${reportName!}${serversPayExpend_index/50000+1}"> <Table> <Column ss:AutoFitWidth="0" ss:Width="100"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Column ss:AutoFitWidth="0" ss:Width="200"/> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="header"><Data ss:Type="String">编号</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">服务器名</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">充值元宝汇总</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">消费元宝汇总</Data></Cell> <Cell ss:StyleID="header"><Data ss:Type="String">剩余元宝汇总</Data></Cell> </Row> </#if> <Row ss:AutoFitHeight="0"> <Cell <#if (serversPayExpend_index%2==0)>ss:StyleID="content"</#if>><Data ss:Type="String">${serversPayExpend_index+1}</Data></Cell> <Cell <#if (serversPayExpend_index%2==0)>ss:StyleID="content"</#if>><Data ss:Type="String">${serversPayExpend.serverName!}</Data></Cell> <Cell <#if (serversPayExpend_index%2==0)>ss:StyleID="content"</#if>><Data ss:Type="String">${serversPayExpend.recharge!}</Data></Cell> <Cell <#if (serversPayExpend_index%2==0)>ss:StyleID="content"</#if>><Data ss:Type="String">${serversPayExpend.expend!}</Data></Cell> <Cell <#if (serversPayExpend_index%2==0)>ss:StyleID="content"</#if>><Data ss:Type="String">${serversPayExpend.remain!}</Data></Cell> </Row> <#if ((serversPayExpend_index+1)%50000==0)> </Table> </Worksheet> </#if> </#list> <#if (serversPayExpendList?size%50000!=0)> </Table> </Worksheet> </#if> </Workbook>
具体如何通过java代码调用请参考人代码
标签:excel报表 freemarker 报表导出 报表
原文地址:http://blog.csdn.net/wpydaguan/article/details/44984047