File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
java/org/apache/poi/xssf/usermodel
testcases/org/apache/poi/xssf/usermodel Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -576,13 +576,17 @@ public XSSFSheet cloneSheet(int sheetNum) {
576
576
// copy drawing contents
577
577
clonedDg .getCTDrawing ().set (dg .getCTDrawing ());
578
578
579
+ clonedDg = clonedSheet .createDrawingPatriarch ();
580
+
579
581
// Clone drawing relations
580
582
List <POIXMLDocumentPart > srcRels = srcSheet .createDrawingPatriarch ().getRelations ();
581
583
for (POIXMLDocumentPart rel : srcRels ) {
582
584
PackageRelationship relation = rel .getPackageRelationship ();
583
- clonedSheet
584
- .createDrawingPatriarch ()
585
- .getPackagePart ()
585
+
586
+ clonedDg .addRelation (relation .getId (), rel );
587
+
588
+ clonedDg
589
+ .getPackagePart ()
586
590
.addRelationship (relation .getTargetURI (), relation .getTargetMode (),
587
591
relation .getRelationshipType (), relation .getId ());
588
592
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
31
31
import java .io .FileInputStream ;
32
32
import java .io .FileOutputStream ;
33
33
import java .io .IOException ;
34
+ import java .io .OutputStream ;
34
35
import java .util .Calendar ;
35
36
import java .util .List ;
36
37
@@ -2262,4 +2263,31 @@ public void testBug56820_Formula2() throws IOException {
2262
2263
wb .close ();
2263
2264
}
2264
2265
}
2266
+
2267
+ @ Test
2268
+ public void test56467 () throws IOException {
2269
+ Workbook wb = XSSFTestDataSamples .openSampleWorkbook ("picture.xlsx" );
2270
+ try {
2271
+ Sheet orig = wb .getSheetAt (0 );
2272
+ assertNotNull (orig );
2273
+
2274
+ Sheet sheet = wb .cloneSheet (0 );
2275
+ Drawing drawing = sheet .createDrawingPatriarch ();
2276
+ for (XSSFShape shape : ((XSSFDrawing ) drawing ).getShapes ()) {
2277
+ if (shape instanceof XSSFPicture ) {
2278
+ XSSFPictureData pictureData = ((XSSFPicture ) shape ).getPictureData ();
2279
+ assertNotNull (pictureData );
2280
+ }
2281
+ }
2282
+
2283
+ // OutputStream out = new FileOutputStream("/tmp/56467.xls");
2284
+ // try {
2285
+ // wb.write(out);
2286
+ // } finally {
2287
+ // out.close();
2288
+ // }
2289
+ } finally {
2290
+ wb .close ();
2291
+ }
2292
+ }
2265
2293
}
You can’t perform that action at this time.
0 commit comments