Bug 55369 - [PATCH] Added implementation for collapsing rows
Summary: [PATCH] Added implementation for collapsing rows
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.10-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2013-08-06 14:34 UTC by Krishna
Modified: 2013-10-20 18:48 UTC (History)
0 users

SVN Diff file (4.22 KB, text/plain)
2013-08-06 14:34 UTC, Krishna
SVN Diff File (8.47 KB, text/plain)
2013-10-10 09:46 UTC, Krishna
SVN Diff File (8.73 KB, text/plain)
2013-10-18 10:59 UTC, Krishna

Note You need to log in before you can comment on or make changes to this bug.
Description Krishna 2013-08-06 14:34:56 UTC
Created attachment 30682 [details]
SVN Diff file

Added implementation for collapsing rows in the API setRowGroupCollapsed in the class SXSSFSheet. Only collapsing part is implemented. It throws RuntimeException for expanding rows.
Comment 1 Krishna 2013-08-12 13:39:40 UTC

Do you need any extra information to take this forward ?

Comment 2 Dominik Stadler 2013-09-29 20:06:54 UTC
Hi, Thanks for the patch, it would be nice to also have unit tests added as part of the patch, can you update your diff with some which verify the added APIs?
Comment 3 Krishna 2013-10-10 09:46:41 UTC
Created attachment 30917 [details]
SVN Diff File
Comment 4 Krishna 2013-10-10 09:47:46 UTC

I have added a Test case and an example to test the new APIs. Let me know if you need anything else.

Comment 5 Dominik Stadler 2013-10-14 20:16:49 UTC
Thanks, I have started to apply this locally to get some testing done before submitting. 

I saw that the error message for rows without group are ugly and don't give the developer a way to know what the actual problem is. 

Exception in thread "main" java.lang.IllegalArgumentException: Invalid row number (-1) outside allowable range (0..1048575)
	at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:91)
	at org.apache.poi.xssf.streaming.SXSSFSheet.collapseRow(SXSSFSheet.java:1154)
	at org.apache.poi.xssf.streaming.SXSSFSheet.setRowGroupCollapsed(SXSSFSheet.java:1133)
	at org.apache.poi.xssf.streaming.examples.Outlining.collapseRow(Outlining.java:44)
	at org.apache.poi.xssf.streaming.examples.Outlining.main(Outlining.java:29)

This is obviously a side-effect of trying to create a row, why is this row-creating done anyway in this case?

Any way we can improve error checking here and throw an error message with better indication of what the problem is instead of this trying to create a row at an invalid location?
Comment 6 Krishna 2013-10-18 10:59:53 UTC
Created attachment 30942 [details]
SVN Diff File

Thanks for the feedback.

I have added few error checks to not allow row group collapsing if the row is not part of the grouping. Also, fixed the code to handle collapsing of the row group starting at row 1.

Comment 7 Dominik Stadler 2013-10-20 18:48:09 UTC
Thanks for the update, committed now as r1533932, I only added a few destructive tests to also cover the error cases.