The XSSFRelation doesn't have a relation of type Custom property. Hence while cloning a sheet (XSSFSheet) containing a custom property relation type, it generates an exception POIXMLException: Can't clone sheet - unknown relation type found: http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty (XSSFWorkbook.java) private static void addRelation(RelationPart rp, POIXMLDocumentPart target) { PackageRelationship rel = rp.getRelationship(); if (rel.getTargetMode() == TargetMode.EXTERNAL) { target.getPackagePart().addRelationship( rel.getTargetURI(), rel.getTargetMode(), rel.getRelationshipType(), rel.getId()); } else { XSSFRelation xssfRel = XSSFRelation.getInstance(rel.getRelationshipType()); if (xssfRel == null) { // Don't copy all relations blindly, but only the ones we know about throw new POIXMLException("Can't clone sheet - unknown relation type found: "+rel.getRelationshipType()); } target.addRelation(rel.getId(), xssfRel, rp.getDocumentPart()); } } You can find more infos here: http://people.apache.org/~centic/poi_regression/reportsAll/
A possible fix: add a new XSSFRelation (XSSFRelation.java) public static final XSSFRelation CUSTOM_PROPERTIES = new XSSFRelation( "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty", "/xl/customProperty#.bin", null );
Can you attch a sample workbook with a custom relation so that we can write a unit test for this? Code that adds a custom relation to a blank workbook works too.
Created attachment 34570 [details] TestCloneSheetWithCustomProperty Here I have attached a sample excel file which contains a custom property (i.e. raises an exception when the contained sheet is to be cloned).
Applied via r1776606, thanks for the suggested patch.