public DynamicReport buildReport() throws Exception {
    initStyles(); // init some styles to be used

    /** Create an empty report (no columns)! */
    FastReportBuilder drb = new FastReportBuilder();
    drb.setTitle("November " + getYear() + " sales report")
        .setSubtitle("This report was generated at " + new Date())
        //			.setPageSizeAndOrientation(Page.Page_A4_Landscape())
        .setPrintColumnNames(false)
        .setUseFullPageWidth(true)
        .setDefaultStyles(titleStyle, null, null, null);

    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();

    drb.addHeaderCrosstab(djcross); // add the crosstab in the header band of the report

    DynamicReport dr = drb.build();

    // put a collection in the parameters map to be used by the crosstab
    params.put(
        "sr", SortUtils.sortCollection(TestRepositoryProducts.getDummyCollection(), djcross));

    return dr;
  }
  public DynamicReport buildReport() throws Exception {
    initStyles(); // init some styles to be used

    /** Create an empty report (no columns)! */
    FastReportBuilder drb = new FastReportBuilder();
    drb.setTitle("November " + getYear() + " sales report")
        .setSubtitle("This report was generated at " + new Date())
        .setPageSizeAndOrientation(Page.Page_A4_Landscape())
        .setPrintColumnNames(false)
        .setUseFullPageWidth(true)
        .setDefaultStyles(titleStyle, null, null, null);

    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("Branch", "branch", String.class.getName(), true)
            .addRow("Product Line", "productLine", String.class.getName(), true)
            .addColumn("State", "state", String.class.getName(), true)
            .addColumn("Item", "item", String.class.getName(), true)
            // this measure won't be displayed. The actual function of this measure is to decide how
            // to format a visible measure
            .addInvisibleMeasure("showAsPrices", Boolean.class.getName(), "showAsPrices")
            .addMeasure(
                "quantity",
                Long.class.getName(),
                DJCalculation.SUM,
                "Time",
                measureStyle2,
                new DjBaseMMValueFormatter() {

                  public String getClassName() {
                    return String.class.getName();
                  }

                  public Object innerEvaluate(
                      Object[] values, Map fields, Map variables, Map parameters) {
                    Boolean measureDecisor = this.getValueFor(values, "showAsPrices");
                    Long val = this.getValueFor(values, "quantity");
                    if (measureDecisor == null) {
                      measureDecisor = Boolean.TRUE;
                    }
                    return measureDecisor ? val.toString() : "$" + val;
                  }
                })
            .setRowStyles(rowHeaderStyle, totalRowStyle, totalRowHeaderStyle)
            .setColumnStyles(colHeaderStyle, totalColStyle, totalColHeaderStyle)
            .setCellDimension(34, 60)
            .setColumnHeaderHeight(30)
            .setRowHeaderWidth(80)
            .build();

    drb.addHeaderCrosstab(djcross); // add the crosstab in the header band of the report

    DynamicReport dr = drb.build();

    // put a collection in the parameters map to be used by the crosstab
    params.put(
        "sr", SortUtils.sortCollection(TestRepositoryProducts.getDummyCollectionSmall(), djcross));

    return dr;
  }