Example usage for org.apache.poi.xssf.usermodel XSSFSheet setActiveCell

List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet setActiveCell

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFSheet setActiveCell.

Prototype

@Override
public void setActiveCell(CellAddress address) 

Source Link

Usage

From source file:org.keyboardplaying.xtt.xlsx.XlsxNormalizer.java

License:Apache License

private void normalizeSheet(XSSFSheet sheet, String activeRange) {
    sheet.setZoom(ZOOM_100);/* ww  w .  j  a  v  a  2 s. c om*/
    sheet.setDisplayGridlines(false);
    sheet.setSelected(false);

    PaneInformation pane = sheet.getPaneInformation();
    if (pane == null) {
        /* Reset cell */
        sheet.setActiveCell(new CellAddress(activeRange));
        /* Reset view */
        sheet.getCTWorksheet().getSheetViews().getSheetViewArray(0)
                .setTopLeftCell(CellAddress.A1.formatAsString());
    } else {
        /* Reset cell */
        sheet.createFreezePane(0, 0); // Remove panes
        sheet.setActiveCell(new CellAddress(activeRange));
        sheet.createFreezePane(pane.getVerticalSplitLeftColumn(), pane.getHorizontalSplitTopRow()); // Reset panes
        /* Reset view */
        sheet.showInPane(pane.getHorizontalSplitPosition(), pane.getVerticalSplitPosition());
    }
}