protected void newPage() {
    addRegions(xlsSheet, regions, wb);
    if (hasTemplate()) {
      xlsSheet = wb.getSheetAt(bean.getReportLayout().getTemplateSheet() - 1);
    } else {
      // for a group name inside sheet name when we create a page we do not have the group name yet
      // so we will have to set the name of the previous sheet (see also finishExport where we set
      // the name of the last sheet(s)
      String sheetName = replaceSheetNameParam(bean.getReportLayout().getSheetNames());
      if ((sheetName == null) || sheetName.isEmpty()) {
        sheetName = String.valueOf(page);
      }
      if (sheetNameContainsGroup(bean.getReportLayout().getSheetNames()) && (page > 1)) {
        // current group is for previous sheet page
        xlsSheet = wb.createSheet(String.valueOf(page));
        wb.setSheetName(page - 2, sheetName);
      } else {
        xlsSheet = wb.createSheet(sheetName);
      }
    }
    xlsSheet.setMargin(
        Sheet.LeftMargin, getInches(bean.getReportLayout().getPagePadding().getLeft()));
    xlsSheet.setMargin(
        Sheet.RightMargin, getInches(bean.getReportLayout().getPagePadding().getRight()));
    xlsSheet.setMargin(
        Sheet.TopMargin, getInches(bean.getReportLayout().getPagePadding().getTop()));
    xlsSheet.setMargin(
        Sheet.BottomMargin, getInches(bean.getReportLayout().getPagePadding().getBottom()));

    if (bean.getReportLayout().getOrientation() == LANDSCAPE) {
      xlsSheet.getPrintSetup().setLandscape(true);
    }

    setPaperSize();

    patriarch = xlsSheet.createDrawingPatriarch();
    buildHeader();
    buildFooter();
    page++;
    // first page header is written by ResultExporter
    if (bean.getReportLayout().isHeaderOnEveryPage() && (page > 2)) {
      try {
        printHeaderBand();
      } catch (QueryException e) {
        e.printStackTrace();
      }
    }
  }
Beispiel #2
0
 /**
  * Sets the size of the margin in inches.
  *
  * @param margin which margin to get
  * @param size the size of the margin
  */
 public void setMargin(short margin, double size) {
   _sh.setMargin(margin, size);
 }