JAsperReport+ireportレポートのエクスポートとデータ分析を実現
30650 ワード
JAsperReport+ireportの組み合わせによるレポートファイル(各種ファイルフォーマットxsl.pdf,rtfなど)の生成エクスポートは、現在オープンソースレポートで最も広く使用されている.プラットフォームの1期が完了した後、機能中のレポートとデータ分析は欠かせません.JasperReport+ireportを使用してexcelレポートをエクスポートする方法を示します.
1.必要JAsperファイルはレポートを生成するテンプレートとしてireportファイルによってコンパイルされる.jrxmlファイルの後に生成されます.これは、JasperReportとireportのバージョンが必ず対応しなければならないことに注意してください.そうしないと、問題が発生する可能性があります.次の書類は.jrxmlファイル:
バックグラウンド実行コードJREXLServlet:
ReportService:
ReportDataSource:
ireportがレポートフォーマットを設計する問題については、自分で探してみましょう.
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がレポートフォーマットを設計する問題については、自分で探してみましょう.