您的位置:首页 > 编程语言 > ASP

Jasper Report(3)--- 用JavaBean Collection做为数据源

2015-08-21 14:10 639 查看
1. 新建Java项目结构如下图所示(该项目中有子报表的知识这里不记录这点知识点):





2. 项目中代码片段

  1.实现JRRewindableDataSource接口里面的方法

package com.iaspec.ireport.common;

import java.util.List;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRRewindableDataSource;

public class GenericDataSource implements JRRewindableDataSource{
int index;
List<PrintRecord> records;

public GenericDataSource(List<PrintRecord> records) {
this.records = records;
this.index = -1;
}

@Override
public Object getFieldValue(JRField jrField) throws JRException {
String fieldName = jrField.getName();
return records.get(index).getValue(fieldName);
}

@Override
public boolean next() throws JRException {
++index;
return index < records.size();
}

public void moveFirst() {
}
}


  2.获取资源文件所在路径:

package com.iaspec.ireport.common;

import java.io.IOException;

public class GetPath {

public String showURL() throws IOException {
return this.getClass().getResource("/").getPath();
}
}


  3.设定公用类:

package com.iaspec.ireport.common;

import java.util.HashMap;
import java.util.Map;

public class PrintRecord {
public static final int KEY_NOT_FOUND = -1;

Map<String, Object> vals;

public PrintRecord() {
vals = new HashMap<String, Object>();
}

public void setValue(String key, Object value) {
vals.put(key, value);
}

public Object getValue(String key) {
Object val = vals.get(key);
if (val == null)
return "";
else
return val;
}

public int getKeyNum() {
return vals.size();
}
}


  4. 封装报表所需的参数

package com.iaspec.ireport.core;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.iaspec.ireport.common.GenericDataSource;
import com.iaspec.ireport.common.PrintRecord;
import com.iaspec.ireport.datasource.GenerateBeans;
import com.iaspec.ireport.dto.DailyReportSumDayDTO;

public class GenerateReportParams {
public static Map<String, Object> generateSumDayReport(String path) {
HashMap<String, Object> params = new HashMap<String, Object>();

params.put("fromDate", "2015/06/08");
params.put("toDate", "2015/06/09");
params.put("presentmentDate", "2015/06/09");
params.put("clearingDate", "2015/06/09");

List<DailyReportSumDayDTO> beanList1 = GenerateBeans.getDailyReportSumDay();
List<PrintRecord> prs1 = new LinkedList<PrintRecord>();

BigDecimal totalPresented1 = BigDecimal.ZERO;
BigDecimal totalPending1 = BigDecimal.ZERO;
BigDecimal totalAccepted1 = BigDecimal.ZERO;
BigDecimal totalRejected1 = BigDecimal.ZERO;
BigDecimal totalError1 = BigDecimal.ZERO;

for(DailyReportSumDayDTO dto : beanList1){
PrintRecord pr = new PrintRecord();
pr.setValue("channel", dto.getChannel());
pr.setValue("customerGroup", dto.getCustomerGroup());
pr.setValue("presented", dto.getPresented());
pr.setValue("pending", dto.getPending());
pr.setValue("accepted", dto.getAccepted());
pr.setValue("rejected", dto.getRejected());
pr.setValue("error", dto.getError());

totalPresented1 = dto.getPresented().add(totalPresented1);
totalPending1 = dto.getPending().add(totalPending1);
totalAccepted1 = dto.getAccepted().add(totalAccepted1);
totalRejected1 = dto.getRejected().add(totalRejected1);
totalError1 = dto.getError().add(totalError1);

prs1.add(pr);
}

params.put("totalPresented1", totalPresented1);
params.put("totalPending1", totalPending1);
params.put("totalAccepted1", totalAccepted1);
params.put("totalRejected1", totalRejected1);
params.put("totalError1", totalError1);
params.put("DataSource1", new GenericDataSource(prs1));

List<DailyReportSumDayDTO> beanList2 = GenerateBeans.getProductTypeSumDay();
List<PrintRecord> prs2 = new LinkedList<PrintRecord>();

BigDecimal totalPresented2 = BigDecimal.ZERO;
BigDecimal totalPending2 = BigDecimal.ZERO;
BigDecimal totalAccepted2 = BigDecimal.ZERO;
BigDecimal totalRejected2 = BigDecimal.ZERO;
BigDecimal totalError2 = BigDecimal.ZERO;

for(DailyReportSumDayDTO dto : beanList2){
PrintRecord pr = new PrintRecord();
pr.setValue("productType", dto.getProductType());
pr.setValue("presented", dto.getPresented());
pr.setValue("pending", dto.getPending());
pr.setValue("accepted", dto.getAccepted());
pr.setValue("rejected", dto.getRejected());
pr.setValue("error", dto.getError());

totalPresented2 = dto.getPresented().add(totalPresented2);
totalPending2 = dto.getPending().add(totalPending2);
totalAccepted2 = dto.getAccepted().add(totalAccepted2);
totalRejected2 = dto.getRejected().add(totalRejected2);
totalError2 = dto.getError().add(totalError2);

prs2.add(pr);
}

params.put("totalPresented2", totalPresented2);
params.put("totalPending2", totalPending2);
params.put("totalAccepted2", totalAccepted2);
params.put("totalRejected2", totalRejected2);
params.put("totalError2", totalError2);
params.put("DataSource2", new GenericDataSource(prs2));
params.put("SUBREPORT_DIR", path);

return params;
}
}


  5.创建Bean

package com.iaspec.ireport.dto;

import java.io.Serializable;
import java.math.BigDecimal;

public class DailyReportSumDayDTO implements Serializable {

private static final long serialVersionUID = 3117545431846603555L;

private String channel;
private String customerGroup;
private BigDecimal presented;
private BigDecimal pending;
private BigDecimal accepted;
private BigDecimal rejected;
private BigDecimal error;
private String productType;

public DailyReportSumDayDTO() {
super();
}

public DailyReportSumDayDTO(String channel, String customerGroup,
BigDecimal presented, BigDecimal pending, BigDecimal accepted,
BigDecimal rejected, BigDecimal error, String productType) {
super();
this.channel = channel;
this.customerGroup = customerGroup;
this.presented = presented;
this.pending = pending;
this.accepted = accepted;
this.rejected = rejected;
this.error = error;
this.productType = productType;
}

public String getChannel() {
return channel;
}

public void setChannel(String channel) {
this.channel = channel;
}

public String getCustomerGroup() {
return customerGroup;
}

public void setCustomerGroup(String customerGroup) {
this.customerGroup = customerGroup;
}

public BigDecimal getPresented() {
return presented;
}

public void setPresented(BigDecimal presented) {
this.presented = presented;
}

public BigDecimal getPending() {
return pending;
}

public void setPending(BigDecimal pending) {
this.pending = pending;
}

public BigDecimal getAccepted() {
return accepted;
}

public void setAccepted(BigDecimal accepted) {
this.accepted = accepted;
}

public BigDecimal getRejected() {
return rejected;
}

public void setRejected(BigDecimal rejected) {
this.rejected = rejected;
}

public BigDecimal getError() {
return error;
}

public void setError(BigDecimal error) {
this.error = error;
}

public String getProductType() {
return productType;
}

public void setProductType(String productType) {
this.productType = productType;
}
}


  6. 封装Bean

package com.iaspec.ireport.datasource;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.iaspec.ireport.dto.DailyReportSumDayDTO;

public class GenerateBeans {
public static List<DailyReportSumDayDTO> getDailyReportSumDay(){

List<DailyReportSumDayDTO> list = new ArrayList<DailyReportSumDayDTO>();

list.add(new DailyReportSumDayDTO("iBanking", "Personal", BigDecimal.valueOf(8888888.99), BigDecimal.valueOf(3333333.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("iBanking", "Business Banking", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("iBanking", "Corporate", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("FCDB", "Personal", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("FCDB", "Business Banking", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("FCDB", "Corporate", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("Corporate website", "Personal", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(6666666.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("Corporate website", "Business Banking", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("Corporate website", "Corporate", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("HKICL portal", "Personal", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("HKICL portal", "Business Banking", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));
list.add(new DailyReportSumDayDTO("HKICL portal", "Corporate", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), ""));

return list;
}

public static List<DailyReportSumDayDTO> getProductTypeSumDay(){

List<DailyReportSumDayDTO> list = new ArrayList<DailyReportSumDayDTO>();

list.add(new DailyReportSumDayDTO("", "", BigDecimal.valueOf(6666666.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), "CASA"));
list.add(new DailyReportSumDayDTO("", "", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), "Credit Card"));
list.add(new DailyReportSumDayDTO("", "", BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), "Loans"));
list.add(new DailyReportSumDayDTO("", "", BigDecimal.valueOf(5555555.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99), BigDecimal.valueOf(9999999.99),BigDecimal.valueOf(9999999.99), "Insurance"));

return list;
}
}


  7.产生报表

package com.iaspec.ireport.test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;

import com.iaspec.ireport.common.GetPath;
import com.iaspec.ireport.core.GenerateReportParams;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperRunManager;

public class GenerateReport {
public static void main(String[] args) throws IOException{
GeneratePDFReport(new GetPath().showURL(), GenerateReportParams.generateSumDayReport(new GetPath().showURL()));
}

private static void GeneratePDFReport(String path, Map<String, Object> sourceData){
try {
byte[] pdfStream = JasperRunManager.runReportToPdf(path + "/main.jasper", sourceData, new JREmptyDataSource());
File file = new File(path + "/report.pdf");
FileOutputStream op = new FileOutputStream(file);
op.write(pdfStream);
op.flush();
op.close();
} catch (IOException e) {
e.printStackTrace();
} catch (JRException e) {
e.printStackTrace();
}
}
}


  8. 主报表

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  -->
<!-- 2015-08-21T14:03:07 -->
<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="main" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="aec5b519-b625-41f6-a025-4d38559e41b0">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="fromDate" class="java.lang.String"/>
<parameter name="toDate" class="java.lang.String"/>
<parameter name="presentmentDate" class="java.lang.String"/>
<parameter name="clearingDate" class="java.lang.String"/>
<parameter name="totalPresented1" class="java.math.BigDecimal"/>
<parameter name="totalPending1" class="java.math.BigDecimal"/>
<parameter name="totalAccepted1" class="java.math.BigDecimal"/>
<parameter name="totalRejected1" class="java.math.BigDecimal"/>
<parameter name="totalError1" class="java.math.BigDecimal"/>
<parameter name="DataSource1" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="DataSource2" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="totalPresented2" class="java.math.BigDecimal"/>
<parameter name="totalPending2" class="java.math.BigDecimal"/>
<parameter name="totalAccepted2" class="java.math.BigDecimal"/>
<parameter name="totalRejected2" class="java.math.BigDecimal"/>
<parameter name="totalError2" class="java.math.BigDecimal"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String"/>
<group name="Group1">
<groupExpression><![CDATA[$V{PAGE_NUMBER}]]></groupExpression>
<groupFooter>
<band height="26">
<subreport>
<reportElement x="0" y="4" width="802" height="20" uuid="886efada-a73b-4085-82e6-fd9bb9de79ee"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalPresented2">
<subreportParameterExpression><![CDATA[$P{totalPresented2}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalPending2">
<subreportParameterExpression><![CDATA[$P{totalPending2}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalAccepted2">
<subreportParameterExpression><![CDATA[$P{totalAccepted2}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalRejected2">
<subreportParameterExpression><![CDATA[$P{totalRejected2}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalError2">
<subreportParameterExpression><![CDATA[$P{totalError2}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{DataSource2}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "sub2.jasper"]]></subreportExpression>
</subreport>
</band>
</groupFooter>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="60" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="40" height="20" uuid="5b9f0876-dad0-41e7-964f-95e17721cdb8"/>
<text><![CDATA[Period :]]></text>
</staticText>
<staticText>
<reportElement x="0" y="20" width="90" height="20" uuid="de730f40-cfcd-4cc9-a921-c15681b48d96"/>
<text><![CDATA[Presentment date :]]></text>
</staticText>
<staticText>
<reportElement x="0" y="40" width="70" height="20" uuid="dd8bd899-66cb-473f-9c7e-662e90091eb8"/>
<text><![CDATA[Clearing date :]]></text>
</staticText>
<staticText>
<reportElement x="261" y="0" width="280" height="20" uuid="31a859b9-73f6-4330-8980-2a372bd5d755"/>
<textElement textAlignment="Center">
<font fontName="Arial Black" isBold="true"/>
</textElement>
<text><![CDATA[China Citic Bank International]]></text>
</staticText>
<staticText>
<reportElement x="236" y="20" width="330" height="20" uuid="18aaca0c-0688-43f1-98e0-ac3dccadcd9c"/>
<textElement textAlignment="Center"/>
<text><![CDATA[e-Cheque Daily Activity Summary Report (Day D)]]></text>
</staticText>
<staticText>
<reportElement x="658" y="0" width="52" height="20" uuid="bada66f8-be8d-408b-becd-dd92d197b8db"/>
<text><![CDATA[Print Date : ]]></text>
</staticText>
<staticText>
<reportElement x="658" y="20" width="52" height="20" uuid="44c04286-222f-46ae-aac3-1b5796c79e0f"/>
<text><![CDATA[Print Time :]]></text>
</staticText>
<textField pattern="yyyy/MM/dd">
<reportElement x="710" y="0" width="92" height="20" uuid="e0e8ea12-b6d2-41f4-af36-665b3c5d8e84"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField pattern="HH:mm:ss">
<reportElement x="710" y="20" width="92" height="20" uuid="a0b2c790-5575-4187-9177-a3cea6256ccb"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="40" y="0" width="58" height="20" uuid="c57b5888-d7b7-42a0-babf-f5a2ce81f65b"/>
<textFieldExpression><![CDATA[$P{fromDate}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="99" y="0" width="10" height="20" uuid="c382e621-5fbe-4e30-8aa1-fb2dbc812e61"/>
<text><![CDATA[to]]></text>
</staticText>
<textField>
<reportElement x="116" y="0" width="70" height="20" uuid="c7cdc348-898d-4d25-83db-22bbc5fa8784"/>
<textFieldExpression><![CDATA[$P{toDate}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="90" y="20" width="60" height="20" uuid="965fe446-7d45-4767-8c24-2ccc8cfcd1f2"/>
<textFieldExpression><![CDATA[$P{presentmentDate}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="70" y="40" width="70" height="20" uuid="7898321a-16f7-4efb-9c98-74d7309ccf14"/>
<textFieldExpression><![CDATA[$P{clearingDate}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="7" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="4" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="22" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="802" height="22" uuid="be070050-2281-4b30-bc69-662a6974868e"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalPresented1">
<subreportParameterExpression><![CDATA[$P{totalPresented1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalPending1">
<subreportParameterExpression><![CDATA[$P{totalPending1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalAccepted1">
<subreportParameterExpression><![CDATA[$P{totalAccepted1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalRejected1">
<subreportParameterExpression><![CDATA[$P{totalRejected1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="totalError1">
<subreportParameterExpression><![CDATA[$P{totalError1}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{DataSource1}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "sub1.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="2" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="2" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="23" splitType="Stretch">
<staticText>
<reportElement x="322" y="0" width="158" height="23" uuid="2b3252f4-b55f-451c-9c7f-897b364aef9a"/>
<textElement textAlignment="Center"/>
<text><![CDATA[*** END OF REPORT ***]]></text>
</staticText>
</band>
</summary>
</jasperReport>


  子报表1:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  -->
<!-- 2015-08-21T14:03:19 -->
<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="sub2" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d1debb0f-5c0a-48aa-a93a-187757ae91dd">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="totalPresented1" class="java.math.BigDecimal"/>
<parameter name="totalPending1" class="java.math.BigDecimal"/>
<parameter name="totalAccepted1" class="java.math.BigDecimal"/>
<parameter name="totalRejected1" class="java.math.BigDecimal"/>
<parameter name="totalError1" class="java.math.BigDecimal"/>
<field name="channel" class="java.lang.String"/>
<field name="customerGroup" class="java.lang.String"/>
<field name="presented" class="java.math.BigDecimal"/>
<field name="pending" class="java.math.BigDecimal"/>
<field name="accepted" class="java.math.BigDecimal"/>
<field name="rejected" class="java.math.BigDecimal"/>
<field name="error" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="140" height="20" uuid="1690f038-e5f1-4132-b706-c911aae641b7"/>
<text><![CDATA[Channel]]></text>
</staticText>
<staticText>
<reportElement x="140" y="0" width="140" height="20" uuid="519c4dda-1400-4f30-8a4e-b65cd1160ae6"/>
<text><![CDATA[Customer Group]]></text>
</staticText>
<staticText>
<reportElement x="280" y="0" width="100" height="20" uuid="cba100cf-b80b-4022-aac8-198b2075eed3"/>
<text><![CDATA[Presented]]></text>
</staticText>
<staticText>
<reportElement x="380" y="0" width="100" height="20" uuid="a7de3d30-b00c-42f7-979b-54b74ff44826"/>
<text><![CDATA[Pending]]></text>
</staticText>
<staticText>
<reportElement x="480" y="0" width="100" height="20" uuid="3b864709-94aa-4c63-8652-f96aa933d76e"/>
<text><![CDATA[Accepted]]></text>
</staticText>
<staticText>
<reportElement x="580" y="0" width="100" height="20" uuid="9362560f-6a19-48fc-875c-26a2fd9b98f8"/>
<text><![CDATA[Rejected]]></text>
</staticText>
<staticText>
<reportElement x="680" y="0" width="100" height="20" uuid="e2666412-78ef-435e-b8c6-72d44508249b"/>
<text><![CDATA[Error]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="2" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="140" height="20" uuid="85584127-02e5-4da2-b47b-350c8b14e9a4"/>
<textFieldExpression><![CDATA[$F{channel}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="140" y="0" width="140" height="20" uuid="5b31982b-0592-4673-a35e-34a7b6a07019"/>
<textFieldExpression><![CDATA[$F{customerGroup}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="0" width="100" height="20" uuid="9f9c54db-08ce-4ffc-b25d-736eda2fc8c8"/>
<textFieldExpression><![CDATA[$F{presented}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="380" y="0" width="100" height="20" uuid="c4e844a8-2d48-478c-9265-4b1280dee581"/>
<textFieldExpression><![CDATA[$F{pending}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="0" width="100" height="20" uuid="592114d8-df5c-4e06-ac85-f074093bcd03"/>
<textFieldExpression><![CDATA[$F{accepted}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="580" y="0" width="100" height="20" uuid="b4d5d370-c299-4de5-a13d-5661563e6f08"/>
<textFieldExpression><![CDATA[$F{rejected}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="680" y="0" width="100" height="20" uuid="66e08821-bf23-4001-9c20-afb657164dbb"/>
<textFieldExpression><![CDATA[$F{error}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="140" height="20" uuid="51bc79c0-9dfe-45f7-a177-227563ab8d4c"/>
<text><![CDATA[Total]]></text>
</staticText>
<textField>
<reportElement x="280" y="0" width="100" height="20" uuid="b6edaf65-05e4-458f-9672-1e2526e7f462"/>
<textFieldExpression><![CDATA[$P{totalPresented1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="380" y="0" width="100" height="20" uuid="841b4a18-0b16-40f9-8bf4-7cda720720e9"/>
<textFieldExpression><![CDATA[$P{totalPending1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="0" width="100" height="20" uuid="8ebb4d0d-1292-40b0-9153-1baac2cf4fc7"/>
<textFieldExpression><![CDATA[$P{totalAccepted1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="580" y="0" width="100" height="20" uuid="698a324f-3f94-4299-919c-05cfda3d2cb7"/>
<textFieldExpression><![CDATA[$P{totalRejected1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="680" y="0" width="100" height="20" uuid="28e2c6c6-3eb9-4a93-ad50-6019cdd8c84e"/>
<textFieldExpression><![CDATA[$P{totalError1}]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>


  子报表2:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  -->
<!-- 2015-08-21T14:03:25 -->
<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="sub1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8392e054-83a8-48b1-b95e-3c40bf5a1143">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="totalPresented2" class="java.math.BigDecimal"/>
<parameter name="totalPending2" class="java.math.BigDecimal"/>
<parameter name="totalAccepted2" class="java.math.BigDecimal"/>
<parameter name="totalRejected2" class="java.math.BigDecimal"/>
<parameter name="totalError2" class="java.math.BigDecimal"/>
<field name="productType" class="java.lang.String"/>
<field name="presented" class="java.math.BigDecimal"/>
<field name="pending" class="java.math.BigDecimal"/>
<field name="accepted" class="java.math.BigDecimal"/>
<field name="rejected" class="java.math.BigDecimal"/>
<field name="error" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="140" height="20" uuid="9b246e53-82ea-4726-a86a-d74a59e42797"/>
<text><![CDATA[Product Type]]></text>
</staticText>
<staticText>
<reportElement x="140" y="0" width="140" height="20" uuid="1809f9c9-a70c-4998-b582-f36c81518abf"/>
<text><![CDATA[Presented]]></text>
</staticText>
<staticText>
<reportElement x="280" y="0" width="100" height="20" uuid="08fea51b-0358-469a-8215-2fa192608884"/>
<text><![CDATA[Pending]]></text>
</staticText>
<staticText>
<reportElement x="380" y="0" width="100" height="20" uuid="19a9f495-f801-4019-821d-77b9e26de74e"/>
<text><![CDATA[Accepted]]></text>
</staticText>
<staticText>
<reportElement x="480" y="0" width="100" height="20" uuid="aad9f333-5254-4389-a7cc-41455b4a5c92"/>
<text><![CDATA[Rejected]]></text>
</staticText>
<staticText>
<reportElement x="580" y="0" width="100" height="20" uuid="27b14062-5dba-412f-81fb-60951d7edd83"/>
<text><![CDATA[Error]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="2" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="140" height="20" uuid="7d71429a-291e-4d2f-a35d-c4a0cc724009"/>
<textFieldExpression><![CDATA[$F{productType}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="140" y="0" width="140" height="20" uuid="cf1a29e2-490c-4e5f-be32-e131292daeb5"/>
<textFieldExpression><![CDATA[$F{presented}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="0" width="100" height="20" uuid="cf1a29e2-490c-4e5f-be32-e131292daeb5"/>
<textFieldExpression><![CDATA[$F{pending}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="380" y="0" width="100" height="20" uuid="cf1a29e2-490c-4e5f-be32-e131292daeb5"/>
<textFieldExpression><![CDATA[$F{accepted}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="0" width="100" height="20" uuid="cf1a29e2-490c-4e5f-be32-e131292daeb5"/>
<textFieldExpression><![CDATA[$F{rejected}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="580" y="0" width="100" height="20" uuid="cf1a29e2-490c-4e5f-be32-e131292daeb5"/>
<textFieldExpression><![CDATA[$F{error}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="140" height="20" uuid="df09d91c-970d-4014-bae0-e585058b132d"/>
<text><![CDATA[Total]]></text>
</staticText>
<textField>
<reportElement x="140" y="0" width="140" height="20" uuid="ed974398-9a6d-45f8-a512-09a2082b47df"/>
<textFieldExpression><![CDATA[$P{totalPresented2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="0" width="100" height="20" uuid="4bbcae9e-f867-4e2c-abe2-da1fa26000bb"/>
<textFieldExpression><![CDATA[$P{totalPending2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="380" y="0" width="100" height="20" uuid="15351679-d011-460b-8067-259b3ef326dd"/>
<textFieldExpression><![CDATA[$P{totalAccepted2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="0" width="100" height="20" uuid="c92a203d-d038-4cad-b084-fc541e127e4b"/>
<textFieldExpression><![CDATA[$P{totalRejected2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="580" y="0" width="100" height="20" uuid="b9155d41-f983-43e2-95a2-11cc8dd0b9eb"/>
<textFieldExpression><![CDATA[$P{totalError2}]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>


  生成PDF效果图





结束!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: