Bug 49253 - setRepeatingRowsAndColumns sets print orientation from landscape to portrait
Summary: setRepeatingRowsAndColumns sets print orientation from landscape to portrait
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-05-05 10:19 UTC by Thomas Herre
Modified: 2011-03-30 18:57 UTC (History)
0 users

Workbook with wrong orientation (3.31 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2010-05-05 10:22 UTC, Thomas Herre
Workbook with correct orientation (3.31 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2010-05-05 10:23 UTC, Thomas Herre

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Herre 2010-05-05 10:19:53 UTC
I have an XSSFWorkbook in which I set the page/print orientation to landscape and set one row/some columns to repeat on each page. After setting the repeating rows and columns, Excel displays orientation portrait instead of the desired landscape.

Test code:

        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet();
        Row row = sheet.createRow(0);
        Cell cell = row.createCell(0);
        cell = row.createCell(1);
        cell = row.createCell(2);
        PrintSetup printSetup = sheet.getPrintSetup();
        workbook.setRepeatingRowsAndColumns(0, 0, 1, 0, 0);
        // printSetup.setValidSettings(true);
        workbook.write(new FileOutputStream(new File("test-landscape.xlsx")));

Now open the file in Excel and check the page settings. 
It displays "portrait". That's wrong!

Now, if you comment in the line: 
and run the test again, the resulting file shows "landscape" again. Correct.

Looking into the sources, I found that in the last statement of method setRepeatingRowsAndColumns, printSetup.setValidSettings(false); is called,
which led me to the described workaround.
Comment 1 Thomas Herre 2010-05-05 10:22:42 UTC
Created attachment 25401 [details]
Workbook with wrong orientation
Comment 2 Thomas Herre 2010-05-05 10:23:47 UTC
Created attachment 25402 [details]
Workbook with correct orientation

This workbook was created using the workaround as described in the bug report.
Comment 3 Nick Burch 2011-03-18 12:06:37 UTC
Filip Defoort reported much the same thing on the mailing list last week. Based on his postings, and this bug report, I think I've fixed this in r1082961 (along with a unit test).
Comment 4 filipdef 2011-03-30 18:57:47 UTC
Thanks for fixing this one - I was just gettin' around to actually filing a bug for it !

- Filip