コード例 #1
0
  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;
  }