Bug 54082 - collapseRow do not works as expected
Summary: collapseRow do not works as expected
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-10-31 17:06 UTC by michele.croci
Modified: 2015-10-29 09:24 UTC (History)
3 users (show)

Output (3.28 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-10-31 17:06 UTC, michele.croci

Note You need to log in before you can comment on or make changes to this bug.
Description michele.croci 2012-10-31 17:06:10 UTC
Created attachment 29536 [details]

I have a nested grouping with one parent and two children. 
The first level is expanded. The first child is expanded and the second one collapsed. I expand/collapse the groups using setRowGroupCollapsed. The problem is that if I set the second child as NOT expanded, the first one is also closed (see attachment)

Here the code:

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelGroupRowTest {

	 * @param args
	public static void main(String[] args) {
		Workbook wb = new XSSFWorkbook();
		Sheet sheet = wb.createSheet("Mysheet");
		sheet.groupRow(1, 20);
		sheet.setRowGroupCollapsed(1, false);
		sheet.groupRow(5, 10);
		sheet.setRowGroupCollapsed(5, false);

		sheet.groupRow(12, 14);
		sheet.setRowGroupCollapsed(12, true);
    FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
		}catch (IOException e){



Comment 1 michele.croci 2012-10-31 17:09:06 UTC
I have looked at the source code, one possible patch would be to modify the writeHidden method in this way:

    private int writeHidden(XSSFRow xRow, int rowIndex, boolean hidden) {
      int level = xRow.getCTRow().getOutlineLevel();
      int currentRow;
      for (currentRow = rowIndex; currentRow < getLastRowNum(); currentRow++) {
          if (getRow(currentRow) == null
                  || getRow(currentRow).getCTRow().getOutlineLevel() < level) {
      return currentRow;
Comment 2 Dmitry Smirnov 2013-02-21 13:08:02 UTC
*** Bug 53582 has been marked as a duplicate of this bug. ***
Comment 3 mcroci 2015-08-13 08:18:11 UTC
still no official fix for this Bug?