jasperReport+ireport实现报表导出和数据分析
jasperReport + ireport组合实现报表文件(各种文件格式xsl.pdf,rtf等)的生成导出是目前开源报表中使用的最为广泛的。在平台一期完成之后,而且功能中报表以及数据分析这块是必不可少的,一下展示如何使用JasperReport + ireport导出excel报表。
1.需要.jasper文件作为生成报表的模板,这个文件是由ireport文件编译.jrxml文件之后生成的。这个需要注意的是JasperReport和ireport的版本一定要对应,否则很可能出问题。下面的文件就是.jrxml文件:
<?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true"> <style name="title" isDefault="false" vAlign="Middle" pattern="" fontName="宋体" fontSize="20" isItalic="false" isUnderline="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="cellCenterNoBorder" isDefault="false" hAlign="Center" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="cellleftNoBorder" isDefault="false" hAlign="Left" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="cellRightNoBorder" isDefault="false" hAlign="Right" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="cellCenterHasBorder" isDefault="false" hAlign="Center" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"> <pen lineWidth="0.5" lineColor="#000000"/> </style> <style name="cellleftHasBorder" isDefault="false" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="cellRightHasBorder" isDefault="false" hAlign="Right" vAlign="Middle" lineSpacing="Single" fontName="宋体" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:\WINDOWS\Fonts\SIMKAI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <field name="PID" class="java.lang.String"/> <field name="PROJECTCODE" class="java.lang.String"/> <field name="SELLER" class="java.lang.String"/> <field name="WITHDRAWDAY" class="java.lang.String"/> <field name="FINANCINGPARTY" class="java.lang.String"/> <field name="PERIOD" class="java.lang.String"/> <field name="PAYMETHOD" class="java.lang.String"/> <field name="PUBLISHDAY" class="java.lang.String"/> <field name="RATE" class="java.lang.String"/> <field name="INTEREST" class="java.lang.String"/> <field name="ENDDAY" class="java.lang.String"/> <field name="FINANCINGAMOUNT" class="java.math.BigDecimal"/> <field name="PROJECTNAME" class="java.lang.String"/> <background> <band splitType="Stretch"/> </background> <title> <band height="1" splitType="Stretch"/> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band height="33" splitType="Stretch"> <staticText> <reportElement style="cellCenterHasBorder" x="0" y="0" width="28" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[序号]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="470" y="0" width="49" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[融资金额]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="519" y="0" width="36" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[利息]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="426" y="0" width="44" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[利率]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="373" y="0" width="53" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[到期日]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="109" y="0" width="34" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[卖方]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="143" y="0" width="42" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[对方提现日]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="185" y="0" width="49" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[融资方]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="234" y="0" width="35" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[期限]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="269" y="0" width="51" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[付款方式]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="320" y="0" width="53" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[发标日期]]></text> </staticText> <staticText> <reportElement style="cellCenterHasBorder" x="28" y="0" width="40" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font isBold="true" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <text><![CDATA[项目编号]]></text> </staticText> <staticText> <reportElement x="68" y="0" width="41" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text><![CDATA[项目名称]]></text> </staticText> </band> </columnHeader> <detail> <band height="33" splitType="Stretch"> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="185" y="0" width="49" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{FINANCINGPARTY}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="234" y="0" width="35" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PERIOD}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="269" y="0" width="51" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PAYMETHOD}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="320" y="0" width="53" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PUBLISHDAY}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="0" y="0" width="28" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PID}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="109" y="0" width="34" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{SELLER}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="519" y="0" width="36" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{INTEREST}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="426" y="0" width="44" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{RATE}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="28" y="0" width="40" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PROJECTCODE}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="373" y="0" width="53" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{ENDDAY}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="470" y="0" width="49" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{FINANCINGAMOUNT}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="68" y="0" width="41" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{PROJECTNAME}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement style="cellCenterHasBorder" stretchType="RelativeToTallestObject" x="143" y="0" width="42" height="33"/> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement> <font pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{WITHDRAWDAY}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band height="58" splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary> </jasperReport>
后台执行代码JREXLServlet:
public class JREXLServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * 生成Excel表格 */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File jasperFile = null; try { Configuration config = new PropertiesConfiguration("config.properties"); jasperFile = new File(config.getString("project.info.report.jasper")); } catch (ConfigurationException e2) { e2.printStackTrace(); } Map<String, String> parameters = new HashMap<String, String>(); JasperPrint jasperPrint = null; try { JasperReport jasperReport = (JasperReport) JRLoader .loadObject(jasperFile); jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new ReportDataSource()); } catch (JRException e) { e.printStackTrace(); } if(null != jasperPrint){ FileBufferedOutputStream fbos = new FileBufferedOutputStream(); JRXlsAbstractExporter exporter = new JRXlsExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fbos); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE); /**不分页**/ exporter.setParameter(JRXlsExporterParameter.IGNORE_PAGE_MARGINS,Boolean.TRUE); /**解决勾选stretch with overflow的折行问题**/ exporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN,Boolean.TRUE); try { exporter.exportReport(); fbos.close(); if (fbos.size() > 0) { response.setContentType("application/xls"); response.setHeader("Content-Disposition", "inline; filename=\"ProjectInfo.xls\""); response.setContentLength(fbos.size()); ServletOutputStream ouputStream = response.getOutputStream(); try { fbos.writeData(ouputStream); fbos.dispose(); ouputStream.flush(); } finally { if (null != ouputStream) { ouputStream.close(); } } } } catch (JRException e1) { e1.printStackTrace(); }finally{ if(null !=fbos){ fbos.close(); fbos.dispose(); } } } } }ReportService:
public class ReportService { public List<ProjectInfoBean> getAllPerson() { List<ProjectInfoBean> projectList = new ArrayList<ProjectInfoBean>(); try{ SqlMapClient sqlMap=DataAccessor.getSession(); projectList = new ProjectDAO(sqlMap).queryProjectInfo(); for(ProjectInfoBean pb : projectList){ /**显示为具体的付款形式**/ if("1".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("一次性还本付息"); }else if("2".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("满标付息到期还本"); }else if("3".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("按月付息到期还本"); }else{ pb.setPAYMETHOD("未标明付款方式"); } /**期限后面加上“天”**/ if(null != pb.getPERIOD() && !"".equals(pb.getPERIOD())){ pb.setPERIOD(pb.getPERIOD() + "天"); } /**利率后面加上“%”**/ if(null != pb.getRATE() && !"".equals(pb.getRATE())){ pb.setRATE(pb.getRATE() + "%"); } /**去掉到期日后面的“.0”**/ if(null != pb.getENDDAY() && !"".equals(pb.getENDDAY())){ pb.setENDDAY(pb.getENDDAY().substring(0, pb.getENDDAY().length()-2)); } /**去掉对方提现日后面的“.0”**/ if(null != pb.getWITHDRAWDAY() && !"".equals(pb.getWITHDRAWDAY())){ pb.setWITHDRAWDAY(pb.getWITHDRAWDAY().substring(0, pb.getWITHDRAWDAY().length()-2)); } /**去掉发标日期后面的“.0”**/ if(null != pb.getPUBLISHDAY() && !"".equals(pb.getPUBLISHDAY())){ pb.setPUBLISHDAY(pb.getPUBLISHDAY().substring(0, pb.getPUBLISHDAY().length()-2)); } } }catch(Exception e){ e.printStackTrace(); } return projectList; } }
ReportDataSource:
public class ReportService { public List<ProjectInfoBean> getAllPerson() { List<ProjectInfoBean> projectList = new ArrayList<ProjectInfoBean>(); try{ SqlMapClient sqlMap=DataAccessor.getSession(); projectList = new ProjectDAO(sqlMap).queryProjectInfo(); for(ProjectInfoBean pb : projectList){ /**显示为具体的付款形式**/ if("1".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("一次性还本付息"); }else if("2".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("满标付息到期还本"); }else if("3".equals(pb.getPAYMETHOD())){ pb.setPAYMETHOD("按月付息到期还本"); }else{ pb.setPAYMETHOD("未标明付款方式"); } /**期限后面加上“天”**/ if(null != pb.getPERIOD() && !"".equals(pb.getPERIOD())){ pb.setPERIOD(pb.getPERIOD() + "天"); } /**利率后面加上“%”**/ if(null != pb.getRATE() && !"".equals(pb.getRATE())){ pb.setRATE(pb.getRATE() + "%"); } /**去掉到期日后面的“.0”**/ if(null != pb.getENDDAY() && !"".equals(pb.getENDDAY())){ pb.setENDDAY(pb.getENDDAY().substring(0, pb.getENDDAY().length()-2)); } /**去掉对方提现日后面的“.0”**/ if(null != pb.getWITHDRAWDAY() && !"".equals(pb.getWITHDRAWDAY())){ pb.setWITHDRAWDAY(pb.getWITHDRAWDAY().substring(0, pb.getWITHDRAWDAY().length()-2)); } /**去掉发标日期后面的“.0”**/ if(null != pb.getPUBLISHDAY() && !"".equals(pb.getPUBLISHDAY())){ pb.setPUBLISHDAY(pb.getPUBLISHDAY().substring(0, pb.getPUBLISHDAY().length()-2)); } } }catch(Exception e){ e.printStackTrace(); } return projectList; } } <span style="font-family:Microsoft YaHei;font-size:14px;"> </span>至于ireport设计报表格式的问题,大家自己去探索吧。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。