Search in sources :

Example 1 with PaneRecord

use of org.apache.poi.hssf.record.PaneRecord in project poi by apache.

the class InternalSheet method createFreezePane.

/**
     * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
     *
     * <p>If both colSplit and rowSplit are zero then the existing freeze pane is removed</p>
     *
     * @param colSplit      Horizonatal position of split.
     * @param rowSplit      Vertical position of split.
     * @param topRow        Top row visible in bottom pane
     * @param leftmostColumn   Left column visible in right pane.
     */
public void createFreezePane(int colSplit, int rowSplit, int topRow, int leftmostColumn) {
    int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
    if (paneLoc != -1)
        _records.remove(paneLoc);
    // If both colSplit and rowSplit are zero then the existing freeze pane is removed
    if (colSplit == 0 && rowSplit == 0) {
        windowTwo.setFreezePanes(false);
        windowTwo.setFreezePanesNoSplit(false);
        SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
        sel.setPane(PaneInformation.PANE_UPPER_LEFT);
        return;
    }
    int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
    PaneRecord pane = new PaneRecord();
    pane.setX((short) colSplit);
    pane.setY((short) rowSplit);
    pane.setTopRow((short) topRow);
    pane.setLeftColumn((short) leftmostColumn);
    if (rowSplit == 0) {
        pane.setTopRow((short) 0);
        pane.setActivePane((short) 1);
    } else if (colSplit == 0) {
        pane.setLeftColumn((short) 0);
        pane.setActivePane((short) 2);
    } else {
        pane.setActivePane((short) 0);
    }
    _records.add(loc + 1, pane);
    windowTwo.setFreezePanes(true);
    windowTwo.setFreezePanesNoSplit(true);
    SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
    sel.setPane((byte) pane.getActivePane());
}
Also used : PaneRecord(org.apache.poi.hssf.record.PaneRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord)

Example 2 with PaneRecord

use of org.apache.poi.hssf.record.PaneRecord in project poi by apache.

the class InternalSheet method createSplitPane.

/**
     * Creates a split pane. Any existing freezepane or split pane is overwritten.
     * @param xSplitPos      Horizonatal position of split (in 1/20th of a point).
     * @param ySplitPos      Vertical position of split (in 1/20th of a point).
     * @param topRow        Top row visible in bottom pane
     * @param leftmostColumn   Left column visible in right pane.
     * @param activePane    Active pane.  One of: PANE_LOWER_RIGHT,
     *                      PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
     * @see #PANE_LOWER_LEFT
     * @see #PANE_LOWER_RIGHT
     * @see #PANE_UPPER_LEFT
     * @see #PANE_UPPER_RIGHT
     */
public void createSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, int activePane) {
    int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
    if (paneLoc != -1)
        _records.remove(paneLoc);
    int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
    PaneRecord r = new PaneRecord();
    r.setX((short) xSplitPos);
    r.setY((short) ySplitPos);
    r.setTopRow((short) topRow);
    r.setLeftColumn((short) leftmostColumn);
    r.setActivePane((short) activePane);
    _records.add(loc + 1, r);
    windowTwo.setFreezePanes(false);
    windowTwo.setFreezePanesNoSplit(false);
    SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
    sel.setPane(PANE_LOWER_RIGHT);
}
Also used : PaneRecord(org.apache.poi.hssf.record.PaneRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord)

Aggregations

PaneRecord (org.apache.poi.hssf.record.PaneRecord)2 SelectionRecord (org.apache.poi.hssf.record.SelectionRecord)2