我正在尝试执行的以下文档,当它在子报表中接收到很少的元素而没有问题时,以下是生成它后的视图
当子报表接收到多个要处理的元素时,这些元素的内容将在报告的带区中溢出。如下图所示
我想要实现的是,不再溢出不再显示的内容,而是显示在新页面中,我尝试将splitType属性从Stretch更改为Prevent,但是它不起作用,我几乎没有经验报告,我不知道从哪里解决问题,是否有必要使用其他类型的组件来实现我的目标?他们可以解释或建议我如何解决该问题。
我正在ubuntu上使用iReport生成它,如果要在Java SE中复制它以打印它而不需要iReport,则可以使用以下类来完成它。
必需的库:
commons-beanutils-1.9.2.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-logging-1.1.1.jar
groovy-2.5.6.jar
itext-pdfa-5.5.5.jar
itextpdf-5.5.5.jar
jasperreports-6.0.0.jar
jasperreports-fonts-6.0.0.jar
源文件必须保存在目录C:\StyledTextReport
chequeReportTest.jrxml
assetBreakdown.jrxml
dueBreakdown.jrxml
https://drive.google.com/drive/folders/1toBnsWNqrzjF20vuQULKDTSkUSwGEY9g?usp=sharing
PdfFromXmlFile.java
package org.o7planning.tutorial.javajasperreport;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jasperturorial.vo.SimpleDataVO;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
public class PdfFromXmlFile {
public static void main(String[] args) throws JRException {
System.out.println("Print...");
// Compile jrxml file.
JasperReport jasperReport = JasperCompileManager
.compileReport("C:\\StyledTextReport\\chequeReportTest.jrxml");
System.out.println(" subreports...");
JasperCompileManager.compileReportToFile("C:\\StyledTextReport\\dueBreakdown.jrxml", "C:\\StyledTextReport\\dueBreakdown.jasper");
JasperCompileManager.compileReportToFile("C:\\StyledTextReport\\assetBreakdown.jrxml", "C:\\StyledTextReport\\assetBreakdown.jasper");
System.out.println("subreports ok");
// Parameters for report
Map<String, Object> parameters = new HashMap<>();
parameters.put("dataSource", "net.sf.jasperreports.engine.JREmptyDataSource@78bfbb1d");
parameters.put("emisionDate", "2019-03-08");
parameters.put("beneficiary", "Lia Waters");
parameters.put("quantity", "100.00000");
parameters.put("amountinword", "hundred dollars");
List<SimpleDataVO> assets = new ArrayList<>();
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
assets.add(new SimpleDataVO());
parameters.put("assets", assets);
// DataSource
// This is simple example, no database.
// then using empty datasource.
JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
parameters, dataSource);
// Make sure the output directory exists.
File outDir = new File("C:/jasperoutput");
outDir.mkdirs();
// Export to PDF.
JasperExportManager.exportReportToPdfFile(jasperPrint,
"C:/jasperoutput/chequeReportTest.pdf");
System.out.println("Done!");
}
}
SimpleDataVO.java
package com.jasperturorial.vo;
public class SimpleDataVO {
String value;
String label;
String value2;
public SimpleDataVO() {
super();
value = "1";
label = "account name";
value2 = "1.0000";
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue2() {
return value2;
}
public void setValue2(String value2) {
this.value2 = value2;
}
}
我将上一课(PdfFromXmlFile)的学分归功于该链接的初学者出色的报告教程
https://o7planning.org/en/10293/calling-jasper-report-from-java-application
作为初学者,任何贡献都是很大的帮助