码迷,mamicode.com
首页 > 其他好文 > 详细

FreeMarker实例讲解

时间:2015-04-10 22:08:22      阅读:217      评论:0      收藏:0      [点我收藏+]

标签: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代码调用请参考人代码


FreeMarker实例讲解

标签:excel报表   freemarker   报表导出   报表   

原文地址:http://blog.csdn.net/wpydaguan/article/details/44984047

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!