<changes>
<release version="3.8-beta4" date="2011-??-??">
+ <action dev="poi-developers" type="fix">51470 - avoid exception when cloning XSSF sheets with background images</action>
<action dev="poi-developers" type="fix">51481 - Fixed autofilters in HSSF to avoid warnings in Excel 2007</action>
<action dev="poi-developers" type="fix">51533 - Avoid exception when changing name of a sheet containing shared formulas</action>
<action dev="poi-developers" type="add">Support for appending images to existing drawings in HSSF</action>
*
* @param part the child to add
*/
- protected final void addRelation(String id,POIXMLDocumentPart part){
+ public final void addRelation(String id,POIXMLDocumentPart part){
relations.put(id,part);
part.incrementRelationCounter();
}
}
clonedSheet.setSelected(false);
+
+ // copy sheet's relations
+ List<POIXMLDocumentPart> rels = srcSheet.getRelations();
+ for(POIXMLDocumentPart r : rels) {
+ PackageRelationship rel = r.getPackageRelationship();
+ clonedSheet.getPackagePart().addRelationship(rel.getTargetURI(), rel.getTargetMode(),rel.getRelationshipType());
+ clonedSheet.addRelation(rel.getId(), r);
+ }
+
return clonedSheet;
}
// assertEquals("FFEEECE1", cA4_EEECE1.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
// assertEquals("FF1F497D", cA5_1F497D.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
}
+
+ public void test51470() throws Exception {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
+ XSSFSheet sh0 = wb.getSheetAt(0);
+ XSSFSheet sh1 = wb.cloneSheet(0);
+ List<POIXMLDocumentPart> rels0 = sh0.getRelations();
+ List<POIXMLDocumentPart> rels1 = sh1.getRelations();
+ assertEquals(1, rels0.size());
+ assertEquals(1, rels1.size());
+
+ assertEquals(rels0.get(0).getPackageRelationship(), rels1.get(0).getPackageRelationship());
+ }
}