目录
1.Excel没出数据前样式图
public void provinceExcel(String year, List<Ysfmdm> ysfmdmList) {
//附表4-2 财政拨款项目预算执行情况表2
List<TableGeneral> budgetFinancialAppropriation42 = financialService.budgetFinancialAppropriation42(ysfmdmList);
//附表4-2 模板数据是一个list集合,便于Excel数据迭代
Map rootMap = new HashMap();
rootMap.put("unitName", unitSimpleName);
rootMap.put("unitCode", ysdm);
rootMap.put("projectList", budgetFinancialAppropriation42);
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?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" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>legend</Author>
<LastAuthor>Administrator</LastAuthor>
<LastPrinted>2017-05-12T12:28:59Z</LastPrinted>
<Created>2008-05-13T02:35:44Z</Created>
<LastSaved>2022-07-12T11:31:40Z</LastSaved>
</DocumentProperties>
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<KSOProductBuildVer dt:dt="string">2052-11.1.0.11830</KSOProductBuildVer>
<ICV dt:dt="string">FC2A2A77E6B14BD8B08D601A90061FB8</ICV>
</CustomDocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowWidth>28800</WindowWidth>
<WindowHeight>12540</WindowHeight>
<ActiveSheet>9</ActiveSheet>
<FirstVisibleSheet>2</FirstVisibleSheet>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/><Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
<Interior/><NumberFormat/><Protection/>
</Style>
<Style ss:ID="s49">
<Alignment ss:Vertical="Center"/><Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
<Interior/><NumberFormat/><Protection/>
</Style>
<Style ss:ID="s50">
<Alignment ss:Vertical="Center" ss:WrapText="1"/><Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/><Interior/>
</Style>
<Style ss:ID="s51">
<Alignment ss:Vertical="Center" ss:WrapText="1"/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/><Interior/>
</Style>
<Style ss:ID="s52">
<Alignment ss:Horizontal="Left" ss:Vertical="Center"/><Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="10"/><Interior/>
</Style>
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。以下是重点
<Worksheet ss:Name="附表4-2财政拨款预算执行情况表">
<Table ss:ExpandedColumnCount="7" ss:ExpandedRowCount="7" x:FullColumns="1" x:FullRows="1"
ss:DefaultColumnWidth="54" ss:DefaultRowHeight="15.6">
<Column ss:Index="1" ss:StyleID="s120" ss:AutoFitWidth="0" ss:Width="72"/>
<Column ss:Index="2" ss:StyleID="s49" ss:AutoFitWidth="0" ss:Width="140.25"/>
<Column ss:StyleID="s49" ss:AutoFitWidth="0" ss:Width="83.25" ss:Span="3"/>
<Column ss:Index="7" ss:StyleID="s49" ss:AutoFitWidth="0" ss:Width="62.25"/>
<Row ss:Height="26.25">
<Cell ss:StyleID="s121"><Data ss:Type="String">附表4-2</Data></Cell>
</Row>
<Row ss:Height="26.25">
<Cell ss:StyleID="s198" ss:MergeAcross="6"><Data ss:Type="String">2021年度${unitName}财政拨款预算执行情况表(按单位)</Data></Cell>
</Row>
<Row ss:Height="26.25">
<Cell ss:StyleID="s199" ss:MergeAcross="6"><Data ss:Type="String">金额单位:万元</Data></Cell>
</Row>
<Row ss:Height="26.25">
<Cell ss:StyleID="s116"><Data ss:Type="String">预算代码</Data></Cell>
<Cell ss:StyleID="s56"><Data ss:Type="String">单位名称</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">上年结转结余</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">本年收入</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">本年支出</Data></Cell>
<Cell ss:StyleID="s124"><Data ss:Type="String">本年结转结余</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">执行率</Data></Cell>
</Row>
<#list projectList as s>
<#if s_index==0>
<Row ss:Height="19">
<Cell ss:StyleID="s125"><Data ss:Type="String">${(s.unitCode)!'-'}</Data></Cell>
<Cell ss:StyleID="s125"><Data ss:Type="String">合计</Data></Cell>
<Cell ss:StyleID="s126"><Data ss:Type="Number">${(s.c)!'0'}</Data></Cell>
<Cell ss:StyleID="s126"><Data ss:Type="Number">${(s.d)!'0'}</Data></Cell>
<Cell ss:StyleID="s126"><Data ss:Type="Number">${(s.e)!'0'}</Data></Cell>
<Cell ss:StyleID="s126"><Data ss:Type="Number">${(s.f)!'0'}</Data></Cell>
<Cell ss:StyleID="s127"><Data ss:Type="String">${(s.g)!'-'}</Data></Cell>
</Row>
<#else>
<Row ss:Height="19">
<Cell ss:StyleID="s67"><Data ss:Type="String">${(s.unitCode)!'-'}</Data></Cell>
<Cell ss:StyleID="s84"><Data ss:Type="String">${(s.unitName)!'-'}</Data></Cell>
<Cell ss:StyleID="s128"><Data ss:Type="Number">${(s.c)!'0'}</Data></Cell>
<Cell ss:StyleID="s128"><Data ss:Type="Number">${(s.d)!'0'}</Data></Cell>
<Cell ss:StyleID="s128"><Data ss:Type="Number">${(s.e)!'0'}</Data></Cell>
<Cell ss:StyleID="s128"><Data ss:Type="Number">${(s.f)!'0'}</Data></Cell>
<Cell ss:StyleID="s129"><Data ss:Type="String">${(s.g)!'-'}</Data></Cell>
</Row>
</#if>
</#list>
<Row ss:Height="19">
<Cell ss:StyleID="s200" ss:MergeAcross="6">
<Data ss:Type="String">注:执行率=本年支出/(上年结转结余+本年收入)</Data>
</Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup><Header/><Footer/><PageMargins x:Right="0.0388888888888889" x:Top="0.550694444444444" x:Bottom="0.472222222222222"/></PageSetup>
<Print><ValidPrinterInfo/><Scale>80</Scale><PaperSizeIndex>9</PaperSizeIndex></Print>
<TopRowVisible>0</TopRowVisible>
<LeftColumnVisible>0</LeftColumnVisible>
<PageBreakZoom>100</PageBreakZoom>
<Panes><Pane><Number>3</Number><ActiveRow>6</ActiveRow><ActiveCol>11</ActiveCol><RangeSelection>R7C12</RangeSelection></Pane></Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
</Workbook>
2.Excel出数据后效果图
3.Word模板部分Java代码
public void provinceWord(String year, String unitCode, Model model) {
Map rootMap = new HashMap();
EmployeeInfoVoF8 employeeInfoVo = iYsf02F8Service.selectYsf02rzqk(listf8, unitCode);
if (!Objects.isNull(employeeInfoVoF81) | !Objects.isNull(employeeInfoVoF82)) {
rootMap.put("hgrs", employeeInfoVoF81.getCsgg());
rootMap.put("jcrs", employeeInfoVoF82.getCsgg());
}
rootMap.put("zzry",employeeInfoVo.getZzry());
rootMap.put("xzry", employeeInfoVo.getXzry());
rootMap.put("syry",employeeInfoVo.getSyry());
rootMap.put("syry1",employeeInfoVo.getSyry());
rootMap.put("cgryr", employeeInfoVo.getCgryr());
rootMap.put("czbz", employeeInfoVo.getCzbz());
rootMap.put("jfzl", employeeInfoVo.getJfzl());
BigDecimal lxry = new BigDecimal(employeeInfoVo.getLxry());
BigDecimal txry = new BigDecimal(employeeInfoVo.getTxry());
BigDecimal ltxry = lxry.add(txry);
rootMap.put("ltxry",ltxry.toString());
rootMap.put("lxry", employeeInfoVo.getLxry());
rootMap.put("txry", employeeInfoVo.getTxry());
rootMap.put("cqpy",employeeInfoVo.getCqpy());
}
4.Word模板部分xml代码
可以用WPS或offers办公软件将文件另存为 .xml格式的文件
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="Times New Roman" w:hAnsi="Times New Roman"
w:eastAsia="方正仿宋_GBK" w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
<w:t>1.2021年末实有在职人员${zzry}人,其中:</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:keepNext w:val="0"/>
<w:keepLines w:val="0"/>
<w:pageBreakBefore w:val="0"/>
<w:widowControl w:val="0"/>
<w:kinsoku/>
<w:wordWrap/>
<w:overflowPunct/>
<w:topLinePunct w:val="0"/>
<w:autoSpaceDE/>
<w:autoSpaceDN/>
<w:bidi w:val="0"/>
<w:adjustRightInd/>
<w:snapToGrid/>
<w:spacing w:line="560" w:lineRule="exact"/>
<w:ind w:firstLine="640" w:firstLineChars="200"/>
<w:textAlignment w:val="auto"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:eastAsia="方正仿宋_GBK"
w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="Times New Roman" w:hAnsi="Times New Roman"
w:eastAsia="方正仿宋_GBK" w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
<w:t>行政人员${xzry}人(海关${hgrs}</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="Times New Roman" w:hAnsi="Times New Roman"
w:eastAsia="方正仿宋_GBK" w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
<w:t>人,警察${jcrs}人);</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:keepNext w:val="0"/>
<w:keepLines w:val="0"/>
<w:pageBreakBefore w:val="0"/>
<w:widowControl w:val="0"/>
<w:kinsoku/>
<w:wordWrap/>
<w:overflowPunct/>
<w:topLinePunct w:val="0"/>
<w:autoSpaceDE/>
<w:autoSpaceDN/>
<w:bidi w:val="0"/>
<w:adjustRightInd/>
<w:snapToGrid/>
<w:spacing w:line="560" w:lineRule="exact"/>
<w:ind w:firstLine="640" w:firstLineChars="200"/>
<w:textAlignment w:val="auto"/>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="Times New Roman" w:hAnsi="Times New Roman"
w:eastAsia="方正仿宋_GBK" w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="Times New Roman" w:hAnsi="Times New Roman"
w:eastAsia="方正仿宋_GBK" w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
<w:t>事业人员${syry}人(参公人员${cgryr}人;财政补助${czbz}人,经费自理${jfzl}人);</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:keepNext w:val="0"/>
<w:keepLines w:val="0"/>
<w:pageBreakBefore w:val="0"/>
<w:widowControl w:val="0"/>
<w:kinsoku/>
<w:wordWrap/>
<w:overflowPunct/>
<w:topLinePunct w:val="0"/>
<w:autoSpaceDE/>
<w:autoSpaceDN/>
<w:bidi w:val="0"/>
<w:adjustRightInd/>
<w:snapToGrid/>
<w:spacing w:line="560" w:lineRule="exact"/>
<w:ind w:firstLine="640" w:firstLineChars="200"/>
<w:textAlignment w:val="auto"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:eastAsia="方正仿宋_GBK"
w:cs="方正仿宋_GBK"/>
<w:color w:val="000000"/>
<w:sz w:val="32"/>
<w:szCs w:val="32"/>
</w:rPr>
</w:pPr>
Word模板效果图