예제 #1
0
  public void format() {

    wb = new XSSFWorkbook();

    Map styles = createStyles(wb);
    Sheet sheet = wb.createSheet("Loan Calculator");
    sheet.setPrintGridlines(false);
    sheet.setDisplayGridlines(false);
    PrintSetup printSetup = sheet.getPrintSetup();
    printSetup.setLandscape(true);
    sheet.setFitToPage(true);
    sheet.setHorizontallyCenter(true);
    sheet.setColumnWidth(0, 768);
    sheet.setColumnWidth(1, 768);
    sheet.setColumnWidth(2, 2816);
    sheet.setColumnWidth(3, 3584);
    sheet.setColumnWidth(4, 3584);
    sheet.setColumnWidth(5, 3584);
    sheet.setColumnWidth(6, 3584);

    Row titleRow = sheet.createRow(0);
    titleRow.setHeightInPoints(35F);
    for (int i = 1; i <= 7; i++)
      titleRow.createCell(i).setCellStyle((CellStyle) styles.get("title"));

    Cell titleCell = titleRow.getCell(2);
    titleCell.setCellValue("Simple");
  }
예제 #2
0
  private void printSetup(Sheet oldSheet, Sheet newSheet) {
    // print setup
    PrintSetup oldPS = oldSheet.getPrintSetup();
    PrintSetup newPS = newSheet.getPrintSetup();

    newPS.setPaperSize(oldPS.getPaperSize());
    newPS.setScale(oldPS.getScale());
    newPS.setPageStart(oldPS.getPageStart());
    newPS.setFitWidth(oldPS.getFitWidth());
    newPS.setFitHeight(oldPS.getFitHeight());
    newPS.setLeftToRight(oldPS.getLeftToRight());
    newPS.setLandscape(oldPS.getLandscape());
    newPS.setValidSettings(oldPS.getValidSettings());
    newPS.setNoColor(oldPS.getNoColor());
    newPS.setDraft(oldPS.getDraft());
    newPS.setNotes(oldPS.getNotes());
    newPS.setNoOrientation(oldPS.getNoOrientation());
    newPS.setUsePage(oldPS.getUsePage());
    newPS.setHResolution(oldPS.getHResolution());
    newPS.setVResolution(oldPS.getVResolution());
    newPS.setHeaderMargin(oldPS.getHeaderMargin());
    newPS.setFooterMargin(oldPS.getFooterMargin());
    newPS.setCopies(oldPS.getCopies());

    newSheet.setRightToLeft(oldSheet.isRightToLeft());
    newSheet.setHorizontallyCenter(oldSheet.getHorizontallyCenter());
    newSheet.setVerticallyCenter(oldSheet.getVerticallyCenter());
    newSheet.setAutobreaks(oldSheet.getAutobreaks());
    newSheet.setDisplayZeros(oldSheet.isDisplayZeros());
    newSheet.setFitToPage(oldSheet.getFitToPage());
    newSheet.setAutobreaks(oldSheet.getAutobreaks());
    newSheet.setPrintGridlines(oldSheet.isPrintGridlines());

    newSheet.getHeader().setCenter(oldSheet.getHeader().getCenter());
    newSheet.getHeader().setLeft(oldSheet.getHeader().getLeft());
    newSheet.getHeader().setRight(oldSheet.getHeader().getRight());

    newSheet.getFooter().setCenter(oldSheet.getFooter().getCenter());
    newSheet.getFooter().setLeft(oldSheet.getFooter().getLeft());
    newSheet.getFooter().setRight(oldSheet.getFooter().getRight());

    newSheet.setMargin(Sheet.LeftMargin, oldSheet.getMargin(Sheet.LeftMargin));
    newSheet.setMargin(Sheet.RightMargin, oldSheet.getMargin(Sheet.RightMargin));
    newSheet.setMargin(Sheet.HeaderMargin, oldSheet.getMargin(Sheet.HeaderMargin));
    newSheet.setMargin(Sheet.FooterMargin, oldSheet.getMargin(Sheet.FooterMargin));
    newSheet.setMargin(Sheet.BottomMargin, oldSheet.getMargin(Sheet.BottomMargin));
    newSheet.setMargin(Sheet.TopMargin, oldSheet.getMargin(Sheet.TopMargin));
  }