Menu

#8 pagination error when using dynamicReportBuilder.

v1.0_(example)
open
nobody
None
5
2014-08-27
2014-08-25
darryl
No

dynamicJasper 5.0.3
java 1.6.0_24

pagination error when using dynamicReportBuilder.
The following code extract works ok for the first page, however when printing over 2 pages.
instead of printing the data on a second pages it overwrites the first pages, and shifts all the columns right by 1 column.
It looks like instead of incrementing the page the column is being incremented.
It happens when exporting to pdf or excel.
If i change the code to use the jasperDesign class it prints ok. It only occurs when using the dynamicReportBuilder class.

a work around or a fix to this problem would be appreciated
thanks
darryl

code extract

DynamicReportBuilder dynamicReportBuilder = new DynamicReportBuilder();

// configure report-level settings
dynamicReportBuilder.setReportName(repTemplate.name);
dynamicReportBuilder.setPageSizeAndOrientation(Page.Page_Letter_Landscape());

//get number of columns
Integer noOfColumns = repTemplate.repColumns.size() + repTemplate.repSummaryColumns.size();
dynamicReportBuilder.setColumnsPerPage(noOfColumns,2)
dynamicReportBuilder.addAutoText(new AutoText(repTemplate.name,
AutoText.POSITION_HEADER, HorizontalBandAlignment.CENTER, 400));

//add loop repcolumn + repsummaryColumn
for (column in repTemplate.repColumns) {
ColumnBuilder columnBuilderID = ColumnBuilder.getNew();
columnBuilderID.setTitle(column.columnlabel);
if (noOfColumns < 10) {
int columnWidth = Math.round(LETTER_LANDSCAPE_PAGE_WIDTH / noOfColumns)
columnBuilderID.setWidth(columnWidth);
//columnBuilderID.setWidth(180);
}
columnBuilderID.setFixedWidth(true);
//remove any reserve charactors
String columnAlias = column.questionname.replaceAll("/","")
columnBuilderID.setColumnProperty(columnAlias, String.class.getName(), column.columnlabel);
dynamicReportBuilder.addColumn(columnBuilderID.build());
}

//add loop repcolumn + repsummaryColumn
for (column in repTemplate.repSummaryColumns) {
ColumnBuilder columnBuilderID = ColumnBuilder.getNew();
columnBuilderID.setTitle(column.columnlabel);
if (noOfColumns < 10) {
int columnWidth = Math.round(LETTER_LANDSCAPE_PAGE_WIDTH / noOfColumns)
columnBuilderID.setWidth(columnWidth);
//columnBuilderID.setWidth(180);
}
columnBuilderID.setFixedWidth(true);
//remove any reserve charactors
String columnAlias = column.columnlabel.replaceAll("/","")
columnBuilderID.setColumnProperty(columnAlias, Integer.class.getName(), column.columnlabel);
// add a footer variable to handle total calculation
//AbstractColumn columnAddition = columnBuilderID.build();
//dynamicReportBuilder.addColumn(columnAddition);
//dynamicReportBuilder.addGlobalFooterVariable(columnAddition, DJCalculation.SUM);
//dynamicReportBuilder.setGrandTotalLegend("Total:");
}

if ( !repTemplate.chartType.equals(CHARTTYPE_NONE)) {
addChartWidget(repTemplate, dynamicReportBuilder)
}

dynamicReportBuilder.setQuery(queryStr,"sql");
DynamicReport dynamicReport = dynamicReportBuilder.build();

HashMap djparams = new HashMap<String, Object="">()
djparams.put("lgovmid",lgovmid)

JasperPrint jasperPrint = DynamicJasperHelper.generateJasperPrint(
dynamicReport, new ClassicLayoutManager(), conn, djparams);
//choose the output format
if (outputType.equals(REPORTTYPE_PDF )) {
exportToPdf(jasperPrint)
}
else if (outputType.equals(REPORTTYPE_EXCEL)) {
exportToExcel(jasperPrint)
}
else if (outputType.equals(REPORTTYPE_HTML)) {
exportToHtml(jasperPrint)
}
else if (outputType.equals(REPORTTYPE_XML)) {
exportToXml(jasperPrint)
}

//------------end of code extract-------------------------------------------------

Discussion

  • Juan Manuel Alvarez

    Plese provide a sample PDF or excel. From code only I cannot help

     
  • darryl

    darryl - 2014-08-27

    i have attached an excel file,
    the top row is offset by one column where it should be the first row on a new page. Let me know if you need anything else.
    thanks
    darryl

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.