public DynamicReport buildReport() throws Exception {
    Style detailStyle = new Style();
    Style headerStyle = new Style();

    Border border = Border.THIN();
    border.setColor(Color.LIGHT_GRAY);
    border.setLineStyle(Border.BORDER_STYLE_DOTTED);

    Font titleFont = Font.ARIAL_BIG_BOLD;
    titleFont.setFontSize(34);

    headerStyle.setBackgroundColor(new Color(230, 230, 230));
    headerStyle.setBorderBottom(Border.THIN());
    headerStyle.setHorizontalAlign(HorizontalAlign.LEFT);
    headerStyle.setVerticalAlign(VerticalAlign.MIDDLE);
    headerStyle.setTransparency(Transparency.OPAQUE);

    detailStyle.setBorderLeft(border);
    detailStyle.setBorderRight(border);

    Style titleStyle = new Style();
    titleStyle.setHorizontalAlign(HorizontalAlign.LEFT);
    titleStyle.setFont(titleFont);
    titleStyle.setTextColor(Color.white);

    Style subtitleStyle = new Style();
    subtitleStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
    subtitleStyle.setTextColor(Color.white);

    /** Creates the DynamicReportBuilder and sets the basic options for the report */
    DynamicReportBuilder drb = new DynamicReportBuilder();
    drb.setTitle(mTitle) // defines the title of the report
        .setSubtitle("generiert mit ArtiVer")
        .setDetailHeight(15) // defines the height for each record of the report
        .setMargins(
            30, 20, 30, 15) // define the margin space for each side (top, bottom, left and right)
        .setDefaultStyles(titleStyle, subtitleStyle, headerStyle, detailStyle)
        .setColumnsPerPage(1); // defines columns per page (like in the telephone guide)

    addColumns(drb, mCols);

    /** add some more options to the report (through the builder) */
    drb.setUseFullPageWidth(true);

    // This look for the resource in the classpath
    File ralPath =
        new File("/eu/gymnaila/chunks/artiver/reports" + "/" + mReportTemplate + ".jrxml");

    if (!ralPath.exists()) {
      ralPath = new File("dist/data/reports/" + mReportTemplate + ".jrxml");
    }
    System.out.println(ralPath.getPath());

    drb.setTemplateFile(ralPath.getPath());

    DynamicReport dr = drb.build();

    return dr;
  }
예제 #2
0
  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;
  }