How to set dynamically isIgnorePagination in jasper report

jasper-reports

I have a jasper file which i export to PDF and Excel as of now i am using only one jasper i want the PDF exported report should be "isIgnorePagination=''true" and for Excel report should be "isIgnorePagination = 'false' "?

How to set from java code?

Best Answer

According to JasperReports sample reference:

For various purposes this flag [isIgnorePagination in jrxml] can be overriden at report filling time using the optional built-in IS_IGNORE_PAGINATION parameter.

So the code should be something like this:

final Map<String, Object> fillingParameters = new HashMap<>();
if (exportType == ExportType.XLS) {
    fillingParameters.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
}
final JasperPrint print = JasperFillManager.fillReport(jasperReport, fillingParameters, dataSource);
Related Topic