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; }