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.setCellValue("1"); cell = row.createCell(1); cell.setCellValue("2"); cell = row.createCell(2); PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true); 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: printSetup.setValidSettings(true); 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.
Created attachment 25401 [details] Workbook with wrong orientation
Created attachment 25402 [details] Workbook with correct orientation This workbook was created using the workaround as described in the bug report.
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).
Thanks for fixing this one - I was just gettin' around to actually filing a bug for it ! - Filip