Bug 51673 - groupRow in SXXSF.Sheet causes unreadable content
Summary: groupRow in SXXSF.Sheet causes unreadable content
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.8-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-17 21:39 UTC by Patrick K
Modified: 2013-06-27 07:52 UTC (History)
0 users



Attachments
Test Class for the GroupRow Issue (1.11 KB, application/octet-stream)
2011-08-17 21:39 UTC, Patrick K
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick K 2011-08-17 21:39:55 UTC
Created attachment 27399 [details]
Test Class for the GroupRow Issue

Using the groupRow method on an SXSSFSheet causes Excel to say it contains unreadable data when opening the workbook.  The rows that were grouped were still active in the sliding window.
Comment 1 Geeya 2011-10-13 21:12:25 UTC
We tried to debug the issue and the issue is in groupRow() method of XSSFSheet object (_sh) in SXSSFSheet. SXSSFSheet.groupRow() calls XSSFSheet.groupRow() method. This method checks if the row exists already, if yes, then create a new row. For some reasons _rows map is empty in XSSFSheet , whereas _rows in SXSSFSheet is populated. So XSSFSheet.groupRow() method overwrites the content by creating a new Row for the same index. In short, SXSSFSheet._rows and XSSFSheet._rows are not in sync and so the rows are corrupted.
Comment 2 Nick Burch 2011-10-17 11:53:13 UTC
It would seem that groupRow will need to be directly implemented on SXSSFSheet, and isn't something that can be delegated down to XSSFSheet

Someone would need to look at the method on XSSFSheet, review the actions it performs, then add a similar thing to SXSSFSheet (working on the sometimes different objects that SXSSF has to hand)
Comment 3 Yegor Kozlov 2012-02-29 10:58:51 UTC
Support for grouping rows in SXSSF has been committed in r1295058

Please note that the rows being grouped must be in the memory window, you cannot write 1000000 rows and then group rows 100-200. 
Workbook wb = new SXSSFWorkbook(100);

        Sheet sh = wb.createSheet();

        for (int rownum = 0; rownum < 1000; rownum++) {
            Row row = sh.createRow(rownum);
            if(rownum == 200)  {
                sh.groupRow(100, 200);
            }

        }

        for (int rownum = 0; rownum < 1000; rownum++) {
            Row row = sh.createRow(rownum);
        }
        sh.groupRow(100, 200);
Comment 4 Yegor Kozlov 2012-02-29 11:01:17 UTC
Please ignore my previous post, I occasionally submitted it too early.

Support for grouping rows in SXSSF has been committed in r1295058

Please note that the rows being grouped must be in the memory window, you cannot write 1000000 rows and then group rows 100-200. 

Examples:

        Workbook wb = new SXSSFWorkbook(100);

        Sheet sh = wb.createSheet();

        for (int rownum = 0; rownum < 1000; rownum++) {
            Row row = sh.createRow(rownum);
            if(rownum == 200)  {
                // correct: group rows while they are in memory
                sh.groupRow(100, 200);
            }

        }

        for (int rownum = 0; rownum < 1000; rownum++) {
            Row row = sh.createRow(rownum);
        }
        // wrong: rows are already flushed and groupRow has no effect
        sh.groupRow(100, 200);

Yegor
Comment 5 Ishmeet 2013-06-27 07:52:14 UTC
Yegor,

How do you group rows that have been flushed, i.e. are not in the memory window now?