Bug 54082

Summary: collapseRow do not works as expected
Product: POI Reporter: michele.croci
Component: XSSFAssignee: POI Developers List <dev>
Status: NEW ---    
Severity: normal CC: michele.croci, onealj, richardjusko
Priority: P2    
Version: 3.8-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Output

Description michele.croci 2012-10-31 17:06:10 UTC
Created attachment 29536 [details]
Output

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) {
		try{
		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");
			wb.write(fileOut);
			fileOut.close();
		}catch (IOException e){

			e.printStackTrace();
		}

	}

}
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) {
              break;
          }else{
          	getRow(currentRow).getCTRow().setHidden(hidden);
          }
      }
      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?