use of org.apache.poi.ss.util.PaneInformation in project poi by apache.
the class XSSFSheet method getPaneInformation.
/**
* Returns the information regarding the currently configured pane (split or freeze).
*
* @return null if no pane configured, or the pane information.
*/
@Override
public PaneInformation getPaneInformation() {
CTPane pane = getDefaultSheetView().getPane();
// no pane configured
if (pane == null) {
return null;
}
CellReference cellRef = pane.isSetTopLeftCell() ? new CellReference(pane.getTopLeftCell()) : null;
return new PaneInformation((short) pane.getXSplit(), (short) pane.getYSplit(), (short) (cellRef == null ? 0 : cellRef.getRow()), (cellRef == null ? 0 : cellRef.getCol()), (byte) (pane.getActivePane().intValue() - 1), pane.getState() == STPaneState.FROZEN);
}
use of org.apache.poi.ss.util.PaneInformation in project poi by apache.
the class BaseTestBugzillaIssues method bug49381.
/**
* CreateFreezePane column/row order check
*/
@Test
public void bug49381() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
int colSplit = 1;
int rowSplit = 2;
int leftmostColumn = 3;
int topRow = 4;
Sheet s = wb.createSheet();
// Populate
for (int rn = 0; rn <= topRow; rn++) {
Row r = s.createRow(rn);
for (int cn = 0; cn < leftmostColumn; cn++) {
Cell c = r.createCell(cn, CellType.NUMERIC);
c.setCellValue(100 * rn + cn);
}
}
// Create the Freeze Pane
s.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow);
PaneInformation paneInfo = s.getPaneInformation();
// Check it
assertEquals(colSplit, paneInfo.getVerticalSplitPosition());
assertEquals(rowSplit, paneInfo.getHorizontalSplitPosition());
assertEquals(leftmostColumn, paneInfo.getVerticalSplitLeftColumn());
assertEquals(topRow, paneInfo.getHorizontalSplitTopRow());
// Now a row only freezepane
s.createFreezePane(0, 3);
paneInfo = s.getPaneInformation();
assertEquals(0, paneInfo.getVerticalSplitPosition());
assertEquals(3, paneInfo.getHorizontalSplitPosition());
assertEquals(0, paneInfo.getVerticalSplitLeftColumn());
assertEquals(3, paneInfo.getHorizontalSplitTopRow());
// Now a column only freezepane
s.createFreezePane(4, 0);
paneInfo = s.getPaneInformation();
assertEquals(4, paneInfo.getVerticalSplitPosition());
assertEquals(0, paneInfo.getHorizontalSplitPosition());
assertEquals(4, paneInfo.getVerticalSplitLeftColumn());
assertEquals(0, paneInfo.getHorizontalSplitTopRow());
wb.close();
}
use of org.apache.poi.ss.util.PaneInformation in project poi by apache.
the class BaseTestSheet method createFreezePane.
@Test
public void createFreezePane() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
// create a workbook
Sheet sheet = wb.createSheet();
assertNull(sheet.getPaneInformation());
sheet.createFreezePane(0, 0);
// still null
assertNull(sheet.getPaneInformation());
sheet.createFreezePane(2, 3);
PaneInformation info = sheet.getPaneInformation();
assertEquals(PaneInformation.PANE_LOWER_RIGHT, info.getActivePane());
assertEquals(3, info.getHorizontalSplitPosition());
assertEquals(3, info.getHorizontalSplitTopRow());
assertEquals(2, info.getVerticalSplitLeftColumn());
assertEquals(2, info.getVerticalSplitPosition());
sheet.createFreezePane(0, 0);
// If both colSplit and rowSplit are zero then the existing freeze pane is removed
assertNull(sheet.getPaneInformation());
sheet.createFreezePane(0, 3);
info = sheet.getPaneInformation();
assertEquals(PaneInformation.PANE_LOWER_LEFT, info.getActivePane());
assertEquals(3, info.getHorizontalSplitPosition());
assertEquals(3, info.getHorizontalSplitTopRow());
assertEquals(0, info.getVerticalSplitLeftColumn());
assertEquals(0, info.getVerticalSplitPosition());
sheet.createFreezePane(3, 0);
info = sheet.getPaneInformation();
assertEquals(PaneInformation.PANE_UPPER_RIGHT, info.getActivePane());
assertEquals(0, info.getHorizontalSplitPosition());
assertEquals(0, info.getHorizontalSplitTopRow());
assertEquals(3, info.getVerticalSplitLeftColumn());
assertEquals(3, info.getVerticalSplitPosition());
sheet.createFreezePane(0, 0);
// If both colSplit and rowSplit are zero then the existing freeze pane is removed
assertNull(sheet.getPaneInformation());
wb.close();
}
Aggregations