Example usage for org.apache.poi.ss.usermodel PrintSetup A4_PAPERSIZE

List of usage examples for org.apache.poi.ss.usermodel PrintSetup A4_PAPERSIZE

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel PrintSetup A4_PAPERSIZE.

Prototype

short A4_PAPERSIZE

To view the source code for org.apache.poi.ss.usermodel PrintSetup A4_PAPERSIZE.

Click Source Link

Document

A4 - 210x297 mm

Usage

From source file:org.projectforge.excel.ExportConfig.java

License:Open Source License

/**
 * Supported values "LETTER", default is "DINA4".
 * @return PrintSetup short value. Default is
 * @see PrintSetup#A4_PAPERSIZE./*from  www  .ja va  2 s.  c  o  m*/
 */
public short getDefaultPaperSizeId() {
    if (excelDefaultPaperSizeValue != -42) {
        return excelDefaultPaperSizeValue;
    }
    if ("LETTER".equals(excelDefaultPaperSize) == true) {
        excelDefaultPaperSizeValue = PrintSetup.LETTER_PAPERSIZE;
    } else {
        excelDefaultPaperSizeValue = PrintSetup.A4_PAPERSIZE;
    }
    return excelDefaultPaperSizeValue;
}

From source file:ro.nextreports.engine.exporter.XlsExporter.java

License:Apache License

private void setPaperSize() {
    String pageFormat = bean.getReportLayout().getPageFormat();
    short size = 0;
    if (ReportLayout.LETTER.equals(pageFormat)) {
        size = PrintSetup.LETTER_PAPERSIZE;
    } else if (ReportLayout.A3.equals(pageFormat)) {
        size = PrintSetup.A3_PAPERSIZE;//from w w w .  ja  v a 2  s  .c o m
    } else if (ReportLayout.A4.equals(pageFormat)) {
        size = PrintSetup.A4_PAPERSIZE;
    } else if (ReportLayout.LEGAL.equals(pageFormat)) {
        size = PrintSetup.LEGAL_PAPERSIZE;
    } else if (ReportLayout.LEDGER.equals(pageFormat)) {
        size = PrintSetup.LEDGER_PAPERSIZE;
    } else if (ReportLayout.TABLOID.equals(pageFormat)) {
        size = PrintSetup.TABLOID_PAPERSIZE;
    }
    if (size != 0) {
        xlsSheet.getPrintSetup().setPaperSize(size);
    }
}

From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils.java

License:Open Source License

/**
 * Convert a BIRT paper size string into a POI PrintSetup.*PAPERSIZE constant.
 * @param name/*  w ww.  j a v  a  2  s .c o m*/
 * The paper size as a BIRT string.
 * @return
 * A POI PrintSetup.*PAPERSIZE constant.
 */
public short getPaperSizeFromString(String name) {
    if ("a4".equals(name)) {
        return PrintSetup.A4_PAPERSIZE;
    } else if ("a3".equals(name)) {
        return PrintSetup.A3_PAPERSIZE;
    } else if ("us-letter".equals(name)) {
        return PrintSetup.LETTER_PAPERSIZE;
    }

    return PrintSetup.A4_PAPERSIZE;
}

From source file:uk.gov.ofwat.fountain.api.table.POITableRenderer.java

License:Open Source License

public Workbook renderTable(XSSFWorkbook workBook, TableStructure tableStructure, DataTable table) {
    this.workBook = workBook;
    creationHelper = workBook.getCreationHelper();

    sheet = workBook.createSheet(table.getCompany().getCode() + " Table " + tableStructure.getTableName());
    PrintSetup printSetup = sheet.getPrintSetup();
    printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE);

    inputDataNumericStyleMap = new HashMap<Short, XSSFCellStyle>();
    copyCellDataNumericStyleMap = new HashMap<Short, XSSFCellStyle>();
    calcDataNumericStyleMap = new HashMap<Short, XSSFCellStyle>();

    yellow = new XSSFColor(new java.awt.Color(255, 255, 0));
    lightYellow = new XSSFColor(new java.awt.Color(255, 255, 224));
    lightBlue = new XSSFColor(new java.awt.Color(224, 255, 255));
    pink = new XSSFColor(new java.awt.Color(255, 204, 204));

    // Styles//from w w  w . j a v a  2 s  .c  om
    // Row header style
    rowHeaderStyle = workBook.createCellStyle();
    // Col header style
    colHeaderStyle = workBook.createCellStyle();
    colHeaderStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    colHeaderStyle.setFillForegroundColor(yellow);
    Font colHeaderFont = workBook.createFont();
    colHeaderFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    colHeaderStyle.setFont(colHeaderFont);
    // Copycell text data cell style
    copyCellTextStyle = workBook.createCellStyle();
    copyCellTextStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    copyCellTextStyle.setFillForegroundColor(pink);
    // Input text data cell style
    inputDataTextStyle = workBook.createCellStyle();
    inputDataTextStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    inputDataTextStyle.setFillForegroundColor(lightYellow);
    // Calc text data cell style
    calcDataTextStyle = workBook.createCellStyle();
    calcDataTextStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    calcDataTextStyle.setFillForegroundColor(lightBlue);
    // Input CG style
    inputCGStyle = workBook.createCellStyle();
    inputCGStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    inputCGStyle.setFillForegroundColor(lightYellow);
    // Input CG style
    copyCellCGStyle = workBook.createCellStyle();
    copyCellCGStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    copyCellCGStyle.setFillForegroundColor(pink);
    // Calc CG style
    calcCGStyle = workBook.createCellStyle();
    calcCGStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    calcCGStyle.setFillForegroundColor(lightBlue);

    // data format
    DataFormat format = workBook.createDataFormat();

    int rownum = 1; // starting point
    Row infoRow1 = sheet.createRow(rownum);
    CellStyle style = workBook.createCellStyle();
    Font font = workBook.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style.setFont(font);

    Cell titleCell1 = infoRow1.createCell(0);
    titleCell1.setCellType(Cell.CELL_TYPE_STRING);
    String DATE_FORMAT = "dd MMM yyyy h:mm";
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    Calendar c1 = Calendar.getInstance(); // today
    String today = sdf.format(c1.getTime());
    RichTextString dateRts = creationHelper.createRichTextString(today + ": "
            + tableStructure.getModelPage().getModel().getCode() + " for " + table.getCompany().getName());
    titleCell1.setCellValue(dateRts);
    titleCell1.setCellStyle(style);
    sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, 0, 9));

    rownum++;
    Row infoRow2 = sheet.createRow(rownum);
    Cell titleCell = infoRow2.createCell(0);
    titleCell.setCellType(Cell.CELL_TYPE_STRING);
    RichTextString rts = creationHelper.createRichTextString(tableStructure.getModelPage().getTable().getName()
            + " - " + tableStructure.getModelPage().getTableDescription());
    titleCell.setCellValue(rts);
    titleCell.setCellStyle(style);
    sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, 0, 4));

    rownum++;
    rownum++;

    if (tableStructure.getModelPage().isGroupSelect()) {
        // group dropdown
        groupSelectTable(tableStructure, table, workBook, sheet, format, rownum);
    } else {
        tableWithoutGroupSelect(tableStructure, table, workBook, sheet, format, rownum);
    }
    return workBook;
}