Bug 32475

Summary: setRepeatingRowsAndColumns only works on 1st and 2nd sheet
Product: POI Reporter: tandyawa
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: joern
Priority: P2    
Version: 3.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Attachments: Defect workbook
Valid workbook

Description tandyawa 2004-12-01 20:09:25 UTC
HSSFWorkbook.setRepeatingRowsAndColumns only work if it's applied to first and 
second sheet only, but it won't work on the subsequent sheets.

No exception, it just won't set the property.

If try to set on first and third sheet, none of the property is set.
So this does not work:
wb.setRepeatingRowsAndColumns(0, -1, -1, 1, 1);
wb.setRepeatingRowsAndColumns(2, -1, -1, 1, 1);

This does not work either:
wb.setRepeatingRowsAndColumns(2, -1, -1, 1, 1);

But this will work fine:
wb.setRepeatingRowsAndColumns(0, -1, -1, 1, 1);
or
wb.setRepeatingRowsAndColumns(1, -1, -1, 1, 1);
or both line all together.
Comment 1 Nick Burch 2008-07-10 16:06:07 UTC
I think this is now working correctly on 3.1 final. Please re-open the bug if you're still having problems with 3.1 final
Comment 2 Joern Muehlencord 2008-08-20 08:59:59 UTC
Does not work with 3.1-final either. 

  @Test
  public void testGenerateExcelFile() throws Exception {
    String fileName = "TestSetRepeatingRowsAndColumns.xls";
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");
    HSSFSheet sheet2 = wb.createSheet("second sheet");

    // Set the columns to repeat from column 0 to 2 on the first sheet
    wb.setRepeatingRowsAndColumns(0, -1, -1, 0, 0);
    // Set the the repeating rows and columns on the second sheet.
    // if the following line is removed, the excel is ok, if added, an error is shown, when opening the workbook
    wb.setRepeatingRowsAndColumns(0, -1, -1, 0, 0);

    try {
      FileOutputStream fileOut = new FileOutputStream(fileName);
      wb.write(fileOut);
      fileOut.close();
      System.out.println ("File written to "+fileOut.toString());
    } catch (Exception ex) {
      fail("Cannot write file!");
    }
  } 
Comment 3 Joern Muehlencord 2008-08-20 09:05:36 UTC
Created attachment 22460 [details]
Defect workbook

Excel file generated with source code provided in comment
Comment 4 Joern Muehlencord 2008-08-20 09:06:30 UTC
Created attachment 22461 [details]
Valid workbook

Valid workbook created with source added in comment
Comment 5 Joern Muehlencord 2008-08-20 09:11:39 UTC
The error is somehow influenced by the name of the sheet - but I could not find the relation. In one of our projects we have a workbook with two sheets - first named "WTU versorgt", second named "eigenversorgt".

The workaround for this issue: we changed the order of the two sheets during creation.  Instead of 
HSSFSheet sheet = workbook.createSheet("WTU versorgt");
HSSFSheet sheet = workbook.createSheet("eigenversorgt");

we have now
HSSFSheet sheet = workbook.createSheet("eigenversorgt");
HSSFSheet sheet = workbook.createSheet("WTU versorgt");

and it works, no error is shown while opening the file.



Comment 6 Joern Muehlencord 2008-08-21 03:14:44 UTC
found bug in Netbeans, one lib dependency was not updated correctly
lib containd old link to 3.0.1
after manual fix all files are generated correctly
works with 3.1 - issue can be closed

Sorry for confusion.