Bug 29713 - setRepeatingRowsAndColumns not working
Summary: setRepeatingRowsAndColumns not working
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: PC other
: P3 normal with 14 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-21 14:02 UTC by Clive Janes
Modified: 2015-06-01 20:40 UTC (History)
0 users



Attachments
Desired print (2.93 KB, image/png)
2015-06-01 19:27 UTC, John Claxton
Details
Actual print using 3.11 (2.32 KB, image/png)
2015-06-01 19:28 UTC, John Claxton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Clive Janes 2004-06-21 14:02:24 UTC
If HSSFWorkbook.setRepeatingRowsAndColumns is not applied to the first sheet 
that gets created in a workbook then it does not work if applied to subsequent 
sheets.
No exceptions are thrown, the property just does not get set for the sheet.

i.e. 
This does not work:
workbook.setRepeatingRowsAndColumns(1, -1, -1, 0, 0);
workbook.setRepeatingRowsAndColumns(0, -1, -1, 0, 0);

This does:
workbook.setRepeatingRowsAndColumns(0, -1, -1, 0, 0);
workbook.setRepeatingRowsAndColumns(1, -1, -1, 0, 0);

The same applies to repeating columns.
Comment 1 Frank Ressel 2006-07-25 11:45:30 UTC
Depending on the sheet name, works setRepeatingRowsAndColumns correct or even 
not. But, I can not find why .....

My TestCase

public class TestRepeatingRowsAndColumns extends TestCase
{
   public void testRepeatingColsRows() throws IOException
   {
      HSSFWorkbook wb = new HSSFWorkbook();

      String[] sheets =

      // Works
      //  {"1234567890123456789012345678901",
      //   "1234567890123456789012345678902",
      //   "1234567890123456789012345678903",
      //   "1234567890123456789012345678904",
      //   "1234567890123456789012345678905"};
         
      // Not Works
      //  {"123456789012345678901234567890ä",
      //   "1234567890123456789012345678902",
      //   "1234567890123456789012345678903",
      //   "1234567890123456789012345678904",
      //   "1234567890123456789012345678905"};

      // But .. Works
      //  {"Bläöü 1",
      //   "Bläöü 2",
      //   "Bläöü 3",
      //   "Bläöü 4",
      //   "Bläöü 5"};

      for (int i = 0; i < sheets.length; i++)
      {
         HSSFSheet s = wb.createSheet(sheets[i]);
         int row = 0;
         getCell(s, row++, 0).setCellValue(
                  new HSSFRichTextString("Print header"));

         for (int j = 1; j < 200; j++)
         {
            getCell(s, row, 0).setCellValue(
                     new HSSFRichTextString("Data line: " + j));
            getCell(s, row, 2).setCellValue(j);
            row++;
         }
         getCell(s, row, 2).setCellFormula("sum(C2:C200)");
      }

      for (int i = 0; i < wb.getNumberOfSheets(); i++)
      {
         wb.setRepeatingRowsAndColumns(i, -1, -1, 0, 0);
      }

      FileOutputStream fos = new FileOutputStream(new File(
               "c://temp//newTestRepeatingColsRows.xls"));
      wb.write(fos);
   }

   private HSSFCell getCell(HSSFSheet s, int rowNum, int columnNum)
   {
      HSSFRow r = s.getRow(rowNum);
      if (r == null)
      {
         r = s.createRow(rowNum);
      }
      HSSFCell cell = r.getCell((short) columnNum);
      if (cell == null)
      {
         cell = r.createCell((short) columnNum);
      }
      return cell;
   }
}
Comment 2 Frank Ressel 2006-07-26 05:01:25 UTC
Error Message in Excel:
German:
    "Name darf integriertem Namen nicht gleichen." ("The name can't be the same
as a build-in name")
    "Alter Name:"  "Drucktitel"
    "Neuer Name:"  <input ("myname")>

"myname" is used in sheet number one, but it is not used as headingrow.
On the other 4 sheets the name in the namebox is "Drucktitel" and it works.

- Occurs On
   MS Excel 2000 (German)
   MS Excel XP   (German)

- Occurs With
   2.5.1-final-20040804
   3.0-alpha2-20060616
Comment 3 Anja Busch 2008-04-24 05:43:13 UTC
I have the same name conflict problem (see comment #2), with a German MS Excel 2003 SP 2, and POI 2.5.1.

But the bug seems not solely to depend on the order of the sheets / the order of the "setRepeatingRowsAndColumns" statements.

In my case, whe have 1-6 sheets. The user selects which of these he wants to print (i.e. create excel sheets). All sheets have print titles. The sheet index is generated at runtime, so we always start with index 0, and the setRepeatingRowsAndColums statements are always in ascending order, according to the sheet index.
Some combinations of sheets work without error, others don't.
For example: 

Selected sheets: A  B  C  D  E  F | Result
----------------------------------------------------
                 -  -  x  x  -  - | Error on sheet C
                 -  -  x  x  -  x | no error
                 x  -  x  x  -  - | Error on sheet A
                 x  -  x  -  -  - | no error
                 x  -  x  x  -  x | no error
                 x  x  x  x  x  - | Error on sheet C
                 x  x  x  x  x  x | no error
...

The combination sheets C + D or C + E (only these two or in combination with others) produce most of the errors. It seems that we get no errors (or very few; I didn't check all combinations) if sheet F is selected.
Comment 4 Nick Burch 2008-04-27 09:36:17 UTC
POI 2.5.1 dates from almost 4 years ago!

Please try again with 3.1 beta 1 (should be hitting the mirrors later today or tomorrow), and re-open the bug if the problem still remains
Comment 5 Anja Busch 2008-12-05 01:27:10 UTC
The error still exists in POI 3.2 Final.
Comment 6 Dominik Stadler 2013-09-20 19:23:35 UTC
I tried with the latest POI 3.10beta2 and could not reproduce this any more, the "this does not work" case also works for me. Please reopen with the files that are generated for both cases if this is still a problem for you.
Comment 7 John Claxton 2015-06-01 19:27:32 UTC
Created attachment 32771 [details]
Desired print
Comment 8 John Claxton 2015-06-01 19:28:40 UTC
Created attachment 32772 [details]
Actual print using 3.11
Comment 9 Dominik Stadler 2015-06-01 20:40:03 UTC
See also bug 57985