/** * @since POI 3.14-Beta1 */ @Override protected POIXMLRelation getDescriptor(String relationshipType) { return XSSFRelation.getInstance(relationshipType); }
/** * @since 3.14-Beta1 */ 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()); } }
/** * @since POI 3.14-Beta1 */ @Override protected POIXMLRelation getDescriptor(String relationshipType) { return XSSFRelation.getInstance(relationshipType); }
private POIXMLRelation getDescriptor(PackageRelationship rel){ if(THEME.getRelation().equals(rel.getRelationshipType())){ return THEME; }else if(PIVOT.getRelation().equals(rel.getRelationshipType())){ return PIVOT; }else if (PIVOT_CACHE.getRelation().equals(rel.getRelationshipType())){ return PIVOT_CACHE; }else if (CONNECTIONS.getRelation().equals(rel.getRelationshipType())){ return CONNECTIONS; }else if (WORKSHEET.getRelation().equals(rel.getRelationshipType())){ return WORKSHEET; } return XSSFRelation.getInstance(rel.getRelationshipType()); }
@Override public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part){ POIXMLRelation descriptor = XSSFRelation.getInstance(rel.getRelationshipType()); if(descriptor == null || descriptor.getRelationClass() == null){ logger.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType()); return new POIXMLDocumentPart(part, rel); } try { Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass(); Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(PackagePart.class, PackageRelationship.class); return constructor.newInstance(part, rel); } catch (Exception e){ throw new POIXMLException(e); } }
public void processSheets( ReportContext reportContext, List<String> savedParts, ZipContentTypeManager manager ) throws Exception { for(int i = 0; i < workBook.getNumberOfSheets(); i++){ XLSXSheet sheet = (XLSXSheet) nextSheet(reportContext, savedParts, i); CommentsTable comments = sheet.getCommentsTable(false); if(comments != null){ String entryName = ZipHelper.getZipItemNameFromOPCName(comments.getPackagePart().getPartName().getName()); savedParts.add(entryName); out.putNextEntry(new ZipEntry(entryName)); comments.writeTo(out); out.closeEntry(); } if (sheet.getPackagePart().hasRelationships()) { PackagePartName relationshipPartName = PackagingURIHelper .getRelationshipPartName(sheet.getPackagePart().getPartName()); ZipPartMarshaller.marshallRelationshipPart(sheet.getPackagePart().getRelationships(), relationshipPartName, out); savedParts.add(relationshipPartName.getName()); for (PackageRelationship next : sheet.getPackagePart().getRelationships()) { PackagePartName name = PackagingURIHelper.createPartName(next.getTargetURI()); XSSFRelation type = XSSFRelation.getInstance(next.getRelationshipType()); if (type != null) { manager.addContentType(name, type.getContentType()); } } } } }
/** * @since 3.14-Beta1 */ 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()); } }