HOW-TO Multiple measure Crosstabs

As easy as invoking the addMeasure(…) from the CrosstabBuilder as many times as measures you need.

multi-measure-crosstab

The above crosstab was generated with a fragment like this:

                DJCrosstab djcross = new CrosstabBuilder()
                        .setHeight(200)
                        .setWidth(500)
                        .setHeaderStyle(mainHeaderStyle)
                        .setDatasource("sr",DJConstants.DATA_SOURCE_ORIGIN_PARAMETER, DJConstants.DATA_SOURCE_TYPE_COLLECTION)
                        .setUseFullWidth(true)
                        .setColorScheme(DJConstants.COLOR_SCHEMA_GRAY)
                        .setAutomaticTitle(true)
                        .setCellBorder(Border.PEN_1_POINT)
                        .addRow("Product Line", "productLine", String.class.getName(),false)
                        .addColumn("State","state",String.class.getName(),false)
                        .addColumn("Branch","branch",String.class.getName(),true)
                        .addColumn("Item", "item", String.class.getName(),true)
                        .addMeasure("id",Long.class.getName(), DJCalculation.SUM , "Id", measureStyle)
                        .addMeasure("amount",Float.class.getName(), DJCalculation.SUM , "Amount",measureStyle2)
                        .setRowStyles(colAndRowHeaderStyle, totalStyle, totalHeaderStyle)
                        .setColumnStyles(colAndRowHeaderStyle, totalStyle, totalHeaderStyle)
                        .setCellDimension(34, 60)
                        .setColumnHeaderHeight(30)
                        .setRowHeaderWidth(80)
                        .build();

code CrosstabReportTest5

More info about crosstabs

Fork me on GitHub