org.apache.poi.xssf.usermodel.XSSFRelation.getInstance()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.apache.poi.xssf.usermodel.XSSFRelation.getInstance()方法的一些代码示例,展示了XSSFRelation.getInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSSFRelation.getInstance()方法的具体详情如下:
包路径:org.apache.poi.xssf.usermodel.XSSFRelation
类名称:XSSFRelation
方法名:getInstance

XSSFRelation.getInstance介绍

[英]Get POIXMLRelation by relation type
[中]按关系类型获取关系

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * @since POI 3.14-Beta1
 */
@Override
protected POIXMLRelation getDescriptor(String relationshipType) {
  return XSSFRelation.getInstance(relationshipType);
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * @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());
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * @since POI 3.14-Beta1
 */
@Override
protected POIXMLRelation getDescriptor(String relationshipType) {
  return XSSFRelation.getInstance(relationshipType);
}

代码示例来源:origin: jbaliuka/x4j-analytic

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());
  
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

@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);
  }
}

代码示例来源:origin: jbaliuka/x4j-analytic

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());
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * @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());
  }
}

相关文章