如何设置Jasper报告中的值

时间:2015-09-23 12:56:03

标签: jasper-reports

如何设置来自不同表格的页脚部分中的Jasper报告中的值?我的意思是说页脚部分有三行,我从视图中获取数据。现在我的要求是在不同页脚行中的不同表格中显示页脚部分的数据(例如-i.e,我使用三个表格的三行)?

1 个答案:

答案 0 :(得分:0)

如何将值作为参数传递?

Java Side

// Call SQL here.
// select value1, value2, value3 from footer_table where ....

Map paramMap = new HashMap();
paramMap.put("value1", "the footer value1");
paramMap.put("value2", "the footer value2");
paramMap.put("value3", "the footer value3");

JasperPrint print = JasperFillManager.fillReport(jasper, paramMap, connection);

// Export to PDF
JasperExportManager.exportReportToPdfFile(print, PdfPath);

Jasper Side

1.添加参数。

name: value1
Parameter Class: java.lang.String

2.将TextFields设置为页脚并设置文本字段表达式。

$P{value1}
$P{value2}
$P{value3}