Example usage for org.apache.poi.ss.usermodel Sheet getRepeatingColumns

List of usage examples for org.apache.poi.ss.usermodel Sheet getRepeatingColumns

Introduction

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

Prototype

CellRangeAddress getRepeatingColumns();

Source Link

Document

Gets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.

Repeating columns cover a range of contiguous columns, e.g.:

 Sheet1!$A:$A Sheet2!$C:$F 
The CellRangeAddress returned contains a row part which spans all rows, and a column part which specifies the contiguous range of repeating columns.

If the Sheet does not have any repeating columns defined, null is returned.

Usage

From source file:org.bbreak.excella.reports.util.ReportsUtil.java

License:Open Source License

/**
 * fromIdx??toIdx?????/*from   w  w  w  .  j a  v  a 2s  . com*/
 * @param workbook fromIdx?toIdx??workbook
 * @param fromIdx ?
 * @param sheet 
 */
public static void copyPrintSetup(Workbook workbook, int fromIdx, Sheet toSheet) {
    Sheet fromSheet = workbook.getSheetAt(fromIdx);
    // ?
    PrintSetup fromPrintSetup = fromSheet.getPrintSetup();
    PrintSetup printSetup = toSheet.getPrintSetup();
    printSetup.setCopies(fromPrintSetup.getCopies());
    printSetup.setDraft(fromPrintSetup.getDraft());
    printSetup.setFitHeight(fromPrintSetup.getFitHeight());
    printSetup.setFitWidth(fromPrintSetup.getFitWidth());
    printSetup.setFooterMargin(fromPrintSetup.getFooterMargin());
    printSetup.setHeaderMargin(fromPrintSetup.getHeaderMargin());
    printSetup.setHResolution(fromPrintSetup.getHResolution());
    printSetup.setLandscape(fromPrintSetup.getLandscape());
    printSetup.setLeftToRight(fromPrintSetup.getLeftToRight());
    printSetup.setNoColor(fromPrintSetup.getNoColor());
    printSetup.setNoOrientation(fromPrintSetup.getNoOrientation());
    printSetup.setPageStart(fromPrintSetup.getPageStart());
    printSetup.setPaperSize(fromPrintSetup.getPaperSize());
    printSetup.setScale(fromPrintSetup.getScale());
    printSetup.setUsePage(fromPrintSetup.getUsePage());
    printSetup.setValidSettings(fromPrintSetup.getValidSettings());
    printSetup.setVResolution(fromPrintSetup.getVResolution());
    // ?
    String printArea = workbook.getPrintArea(fromIdx);
    if (printArea != null) {
        if (printArea.contains("!")) {
            printArea = printArea.substring(printArea.indexOf("!") + 1);
        }
        int toIdx = workbook.getSheetIndex(toSheet);
        workbook.setPrintArea(toIdx, printArea);
    }
    // ?
    toSheet.setRepeatingColumns(fromSheet.getRepeatingColumns());
    toSheet.setRepeatingRows(fromSheet.getRepeatingRows());
}