问题
I'm using the DynamicJasper library for report building in a JavaEE webapp as I'm fed up with Jaspersoft and there seems to be no other java based report creating tool which is open source and good. Please enlighten me if any of you know a better one.
Currently I have two issues, I can't seem to stack the AutoText Boxes in the footer (in the header is fine), only one or two will show depending on.......erm.....I don't have an answer for that. Does anyone know if something like this is possible?
.addAutoText(footerText)
.addAutoText(boxedText)
.addAutoText(xyText)
I can't get the total for a whole column as a group and I've checked nearly everything I could possibly find to try and sort this out but am still failing to do it.
As you can see here, I've got the total of each row under the total for each row (yey!) but I could really use the entire column to total. Does anyone know why this might be?
AbstractColumn costCol = ColumnBuilder.getNew()
.setColumnProperty("cost", Double.class.getName())
.setTitle("Cost")
.setWidth(30)
.setStyle(DynamicJasperStyle.columnStyle(DjValues.INVOICE_COLUMN_SIZE, DjValues.CENTRE, "£0.00"))
.setHeaderStyle(DynamicJasperStyle.columnHeaderStyle(DjValues.INVOICE_COLUMN_SIZE, DjValues.CENTRE))
.build();
GroupBuilder gBuilder = new GroupBuilder();
DJGroup sumGroup = gBuilder.setCriteriaColumn((PropertyColumn) costCol)
.addFooterVariable(costCol,DJCalculation.SUM)
.build();
dr = frb.setGrandTotalLegend("total")
.addColumn(descCol)
.addColumn(qtyCol)
.addColumn(costCol)
.addGroup(sumGroup)
.build();
drb.addConcatenatedReport(dr, new ClassicLayoutManager(), "FakeInvoiceItem", DJConstants.DATA_SOURCE_ORIGIN_PARAMETER, DJConstants.DATA_SOURCE_TYPE_COLLECTION, false);
Where drb = DynamicReportBuilder, dr = DynamicReport and frb = FastReportBuilder.
My style methods look like;
static public Style columnStyle(int font_weight, String orientation, String pattern)
{
Style columnStyle = new Style();
columnStyle.setHorizontalAlign(HorizontalAlign.CENTER);
columnStyle.setPaddingTop(8);
columnStyle.setPaddingBottom(8);
columnStyle.setFont(new Font(font_weight,"DejaVu Serif",false));
if (orientation.equals(DjValues.CENTRE))
{
columnStyle.setHorizontalAlign(HorizontalAlign.CENTER);
}
else if (orientation.equals(DjValues.LEFT))
{
columnStyle.setHorizontalAlign(HorizontalAlign.LEFT);
}
else if(orientation.equals(DjValues.RIGHT))
{
columnStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
}
if (!StringUtils.isNullOrEmpty(pattern))
{
columnStyle.setPattern(pattern);
}
return columnStyle;
}
来源:https://stackoverflow.com/questions/54754683/how-to-get-total-price-with-whole-column-not-each-entry-and-group-title-in-d