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 { Style style = new StyleBuilder(true).setHorizontalAlign(HorizontalAlign.CENTER).build(); Style defStyle = new StyleBuilder(true) .setBorderBottom(Border.THIN()) .setStretching(Stretching.RELATIVE_TO_TALLEST_OBJECT) .setPaddingBottom(3) .setPaddingTop(3) .build(); /** Creates the DynamicReportBuilder and sets the basic options for the report */ FastReportBuilder drb = new FastReportBuilder(); Style title = null; Style subtitle = null; Style columnHeader = null; drb.addColumn("State", "state", String.class.getName(), 20, defStyle) .addColumn("Branch", "branch", String.class.getName(), 30, defStyle) .addColumn("Quantity", "quantity", Long.class.getName(), 60, defStyle, null, true) .addColumn("Amount", "amount", Float.class.getName(), 70, defStyle, null, true) .addBarcodeColumn( "Bar-Code", "amount", Long.class.getName(), BarcodeTypes.USD3, true, false, null, 100, true, ImageScaleMode.FILL, defStyle) .addGroups(1) .setDetailHeight(30) .addField("productLine", String.class.getName()) .setTitle("November" + getYear() + " sales report") .setSubtitle("This report was generated at " + new Date()) .setDefaultStyles(title, subtitle, columnHeader, defStyle) .setUseFullPageWidth(true); DynamicReport dr = drb.build(); return dr; }
public DynamicReport buildReport() throws Exception { /** Creates the DynamicReportBuilder and sets the basic options for the report */ FastReportBuilder drb = new FastReportBuilder(); Style tStyle = new Style(); Style headerStyle = new Style(); headerStyle.setBackgroundColor(Color.cyan); Font font = new Font(); font.setFontName("Arial"); font.setFontSize(10); headerStyle.setFont(font); headerStyle.setHorizontalAlign(HorizontalAlign.LEFT); tStyle.setFont(Font.ARIAL_BIG_BOLD); tStyle.setTextColor(Color.BLUE); AbstractColumn columnName = ColumnBuilder.getNew() .setColumnProperty("name", String.class.getName()) .setTitle("Orientation") .setStyle(headerStyle) .build(); AbstractColumn columnEntryDate = ColumnBuilder.getNew() .setColumnProperty("entryDate", String.class.getName()) .setTitle("") .setStyle(headerStyle) .build(); /*drb.addColumn("State", "state", String.class.getName(),30) .addColumn("Branch", "branch", String.class.getName(),30) .addColumn("Product Line", "productLine", String.class.getName(),50) .addColumn("Item", "item", String.class.getName(),50) .addColumn("Item Code", "id", Long.class.getName(),30,true) .addColumn("Quantity", "quantity", Long.class.getName(),60,true) .addColumn("Amount", "amount", Float.class.getName(),70,true)*/ drb.addColumn(columnName) .addColumn(columnEntryDate) // .addColumn("Student Name","name", String.class.getName(),40) // .addColumn("Entry Date","entryDate", String.class.getName(),30) // .addGroups(0) .addImageBanner( System.getProperty("user.dir") + "/WebContent/generated/reports/images/logo.jpg", new Integer(120), new Integer(76), ImageBanner.ALIGN_LEFT, ImageScaleMode.FILL) .setTitle("Class List") .setTitleStyle(tStyle) .setSubtitle("Boynton Beach on " + valid8r.convertDate(new Date().toString())) .setPrintBackgroundOnOddRows(true) .setUseFullPageWidth(true); drb.addGlobalFooterVariable( drb.getColumn(1), DJCalculation.COUNT, null, new DJValueFormatter() { public String getClassName() { return String.class.getName(); } public Object evaluate(Object value, Map fields, Map variables, Map parameters) { return (value == null ? "0" : value.toString()) + " Students"; } }); DynamicReport dr = drb.build(); 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; }