See answer in https://stackoverflow.com/questions/73043152/is-there-a-way-to-create-a-split-plane-horizontally-using-the-apache-poi-library The constant fields in Sheet are as follows: PANE_LOWER_RIGHT 0 PANE_UPPER_RIGHT 1 PANE_LOWER_LEFT 2 PANE_UPPER_LEFT 3 But the corresponding values in org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane are: INT_BOTTOM_RIGHT 1 INT_TOP_RIGHT 2 INT_BOTTOM_LEFT 3 INT_TOP_LEFT 4 To get PANE_UPPER_LEFT, you need: sheet.createSplitPane(0, 100*20, 0, 9, Sheet.PANE_UPPER_LEFT+1); We probably can't just change the Sheet values because other people might already use the workaround. So let's deprecate the old values and add new ones.
https://github.com/apache/poi/pull/362
Your fixes for HSSF might be wrong as the binary PaneTypes *are* 0-based. See: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-xls/016387b9-9dac-43df-b226-34800b3c2198. But the pane in SelectionRecord seems always be 3 (PANE_UPPER_LEFT) when split pane is set. Actually InternalSheet.createSplitPane always sets PANE_LOWER_RIGHT. That seems to be wrong. Code to check: import java.io.FileInputStream; import org.apache.poi.hssf.usermodel.*; class ReadHSSFSplitPane { public static void main(String[] args) throws Exception { try ( HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream("./Excel.xls")) ) { HSSFSheet sheet = workbook.getSheetAt(0); org.apache.poi.hssf.model.InternalSheet internalSheet = sheet.getSheet(); org.apache.poi.hssf.record.PaneRecord pane = (org.apache.poi.hssf.record.PaneRecord)internalSheet.findFirstRecordBySid(org.apache.poi.hssf.record.PaneRecord.sid); System.out.println(pane); org.apache.poi.hssf.record.SelectionRecord sel = (org.apache.poi.hssf.record.SelectionRecord)internalSheet.findFirstRecordBySid(org.apache.poi.hssf.record.SelectionRecord.sid); System.out.println(sel); } } } Pane in sel is always 3, independent of what split panes are set.
Thanks Axel - I just spotted that the HSSF panel numbers are ok and that the issue with needing the +1 is XSSF only. I have adjusted https://github.com/apache/poi/pull/362
added r1902876 XSSFSheet createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) still has the bug where you need to add 1 to the activePane value (because https://stackoverflow.com/questions/73043152/is-there-a-way-to-create-a-split-plane-horizontally-using-the-apache-poi-library tells users to do that). XSSFSheet createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, PaneType activePane) is the new method that works as expected