<changes>
<release version="3.8-beta2" date="2011-??-??">
+ <action dev="poi-developers" type="fix">49253 - When setting repeating rows and columns for XSSF, don't break the print settings if they were already there</action>
<action dev="poi-developers" type="fix">49219 - ExternalNameRecord support for DDE Link entries without an operation</action>
<action dev="poi-developers" type="fix">50846 - More XSSFColor theme improvements, this time for Cell Borders</action>
<action dev="poi-developers" type="fix">50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not</action>
String reference = getReferenceBuiltInRecord(name.getSheetName(), startColumn, endColumn, startRow, endRow);
name.setRefersToFormula(reference);
- XSSFPrintSetup printSetup = sheet.getPrintSetup();
- printSetup.setValidSettings(false);
+ // If the print setup isn't currently defined, then add it
+ // in but without printer defaults
+ // If it's already there, leave it as-is!
+ CTWorksheet ctSheet = sheet.getCTWorksheet();
+ if(ctSheet.isSetPageSetup() && ctSheet.isSetPageMargins()) {
+ // Everything we need is already there
+ } else {
+ // Have initial ones put in place
+ XSSFPrintSetup printSetup = sheet.getPrintSetup();
+ printSetup.setValidSettings(false);
+ }
}
private static String getReferenceBuiltInRecord(String sheetName, int startC, int endC, int startR, int endR) {
assertEquals("Tabella1", t.getDisplayName());
assertEquals("A1:C3", t.getCTTable().getRef());
}
+
+ /**
+ * Setting repeating rows and columns shouldn't break
+ * any print settings that were there before
+ */
+ public void test49253() throws Exception {
+ XSSFWorkbook wb1 = new XSSFWorkbook();
+ XSSFWorkbook wb2 = new XSSFWorkbook();
+
+ // No print settings before repeating
+ XSSFSheet s1 = wb1.createSheet();
+ assertEquals(false, s1.getCTWorksheet().isSetPageSetup());
+ assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
+
+ wb1.setRepeatingRowsAndColumns(0, 2, 3, 1, 2);
+
+ assertEquals(true, s1.getCTWorksheet().isSetPageSetup());
+ assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
+
+ XSSFPrintSetup ps1 = s1.getPrintSetup();
+ assertEquals(false, ps1.getValidSettings());
+ assertEquals(false, ps1.getLandscape());
+
+
+ // Had valid print settings before repeating
+ XSSFSheet s2 = wb2.createSheet();
+ XSSFPrintSetup ps2 = s2.getPrintSetup();
+ assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
+ assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
+
+ ps2.setLandscape(false);
+ assertEquals(true, ps2.getValidSettings());
+ assertEquals(false, ps2.getLandscape());
+
+ wb2.setRepeatingRowsAndColumns(0, 2, 3, 1, 2);
+
+ ps2 = s2.getPrintSetup();
+ assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
+ assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
+ assertEquals(true, ps2.getValidSettings());
+ assertEquals(false, ps2.getLandscape());
+ }
}