--- src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java 2015-01-17 17:58:04.361835949 +0200 +++ src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java 2015-01-19 10:08:10.993864745 +0200 @@ -1140,6 +1138,34 @@ ct.addNewSheetFormatPr(); if(outlineLevelRow > 0) pr.setOutlineLevelRow((short)outlineLevelRow); } + + /** + * Set row groupings (like groupRow) in a stream-friendly manner + * + *

+ * groupRows requires all rows in the group to be in the current window. + * This is not always practical. Instead use setRowOutlineLevel to + * explicitly set the group level. Level 1 is the to level group, + * followed by 2, etc. It is up to the user to ensure that level 2 + * groups are correctly nested under level 1, etc. + *

+ * + * @param rownum index of row to update (0-based) + * @param level outline level (> 0) + */ + public void setRowOutlineLevel(int rownum, int level) + { + SXSSFRow row = _rows.get(new Integer(rownum)); + row.setOutlineLevel(level); + if(level > 0 && level > outlineLevelRow) { + outlineLevelRow = level; + CTWorksheet ct = _sh.getCTWorksheet(); + CTSheetFormatPr pr = ct.isSetSheetFormatPr() ? + ct.getSheetFormatPr() : + ct.addNewSheetFormatPr(); + pr.setOutlineLevelRow((short)outlineLevelRow); + } + } /** * Ungroup a range of rows that were previously groupped