// copy drawing contents
clonedDg.getCTDrawing().set(dg.getCTDrawing());
+ clonedDg = clonedSheet.createDrawingPatriarch();
+
// Clone drawing relations
List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations();
for (POIXMLDocumentPart rel : srcRels) {
PackageRelationship relation = rel.getPackageRelationship();
- clonedSheet
- .createDrawingPatriarch()
- .getPackagePart()
+
+ clonedDg.addRelation(relation.getId(), rel);
+
+ clonedDg
+ .getPackagePart()
.addRelationship(relation.getTargetURI(), relation.getTargetMode(),
relation.getRelationshipType(), relation.getId());
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Calendar;
import java.util.List;
wb.close();
}
}
+
+ @Test
+ public void test56467() throws IOException {
+ Workbook wb = XSSFTestDataSamples.openSampleWorkbook("picture.xlsx");
+ try {
+ Sheet orig = wb.getSheetAt(0);
+ assertNotNull(orig);
+
+ Sheet sheet = wb.cloneSheet(0);
+ Drawing drawing = sheet.createDrawingPatriarch();
+ for (XSSFShape shape : ((XSSFDrawing) drawing).getShapes()) {
+ if (shape instanceof XSSFPicture) {
+ XSSFPictureData pictureData = ((XSSFPicture) shape).getPictureData();
+ assertNotNull(pictureData);
+ }
+ }
+
+// OutputStream out = new FileOutputStream("/tmp/56467.xls");
+// try {
+// wb.write(out);
+// } finally {
+// out.close();
+// }
+ } finally {
+ wb.close();
+ }
+ }
}