org.apache.poi.xssf.usermodel.XSSFRelation类的使用及代码示例

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

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

XSSFRelation介绍

[英]Defines namespaces, content types and normal file names / naming patterns, for the well-known XSSF format parts.
[中]为众所周知的XSSF格式部分定义名称空间、内容类型和常规文件名/命名模式。

代码示例

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

/**
 * Opens up the Shared Strings Table, parses it, and
 * returns a handy object for working with
 * shared strings.
 */
public SharedStringsTable getSharedStringsTable() throws IOException, InvalidFormatException {
  ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType());
  return parts.size() == 0 ? null : new SharedStringsTable(parts.get(0));
}

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

private void loadUrlsFromSheetRels(PackagePart sheetPart) {
  try {
    for (PackageRelationship rel : sheetPart.getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation())) {
      relIdToHyperlink.put(rel.getId(), rel.getTargetURI().toString());
    }
  } catch (InvalidFormatException e) {
    //swallow
  }
}

代码示例来源: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

int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1;
while(loop) {
  loop = false;
  for (PackagePart packagePart : getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType())) {
    String fileName = XSSFRelation.TABLE.getFileName(tableNumber);
    if(fileName.equals(packagePart.getPartName().getName())) {

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

/**
 * Create a new SpreadsheetML package and setup the default minimal content
 */
protected static OPCPackage newPackage() {
  try {
    OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
    // Main part
    PackagePartName corePartName = PackagingURIHelper.createPartName(XSSFRelation.WORKBOOK.getDefaultFileName());
    // Create main part relationship
    pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
    // Create main document part
    pkg.createPart(corePartName, XSSFRelation.WORKBOOK.getContentType());
    pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
    return pkg;
  } 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.poi/poi-ooxml

/**
 * Returns an InputStream to read the contents of the
 * shared strings table.
 */
public InputStream getSharedStringsData() throws IOException, InvalidFormatException {
  return XSSFRelation.SHARED_STRINGS.getContents(workbookPart);
}

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

/**
 * Create a new SpreadsheetML package and setup the default minimal content
 */
protected static OPCPackage newPackage(XSSFWorkbookType workbookType) {
  try {
    OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());    // NOSONAR - we do not want to close this here
    // Main part
    PackagePartName corePartName = PackagingURIHelper.createPartName(XSSFRelation.WORKBOOK.getDefaultFileName());
    // Create main part relationship
    pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
    // Create main document part
    pkg.createPart(corePartName, workbookType.getContentType());
    pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
    return pkg;
  } catch (Exception e){
    throw new POIXMLException(e);
  }
}

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

String sheetName = XSSFRelation.WORKSHEET.getFileName(sheetNumber);
for(POIXMLDocumentPart relation : getRelations()) {
  if(relation.getPackagePart() != null &&

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

int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1;
while(loop) {
  loop = false;
  for (PackagePart packagePart : getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType())) {
    String fileName = XSSFRelation.TABLE.getFileName(tableNumber);
    if(fileName.equals(packagePart.getPartName().getName())) {

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

/**
 * Returns an InputStream to read the contents of the
 * styles table.
 */
public InputStream getStylesData() throws IOException, InvalidFormatException {
  return XSSFRelation.STYLES.getContents(workbookPart);
}

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

if(part.getSize() == 0 && part.getPartName().getName().equals(XSSFRelation.SHARED_STRINGS.getDefaultFileName())) {
  return true;

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

String sheetName = XSSFRelation.WORKSHEET.getFileName(sheetNumber);
for(POIXMLDocumentPart relation : getRelations()) {
  if(relation.getPackagePart() != null &&

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

/**
 * Get the document's embedded files.
 */
@Override
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
  List<PackagePart> embedds = new LinkedList<>();
  for(XSSFSheet sheet : sheets){
    // Get the embeddings for the workbook
    for(PackageRelationship rel : sheet.getPackagePart().getRelationshipsByType(XSSFRelation.OLEEMBEDDINGS.getRelation())) {
      embedds.add( sheet.getPackagePart().getRelatedPart(rel) );
    }
    for(PackageRelationship rel : sheet.getPackagePart().getRelationshipsByType(XSSFRelation.PACKEMBEDDINGS.getRelation())) {
      embedds.add( sheet.getPackagePart().getRelatedPart(rel) );
    }
  }
  return embedds;
}

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

/**
 * Are we a normal workbook (.xlsx), or a
 *  macro enabled workbook (.xlsm)?
 */
public boolean isMacroEnabled() {
  return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
}

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

/**
 * Returns an InputStream to read the contents of the
 * themes table.
 */
public InputStream getThemesData() throws IOException, InvalidFormatException {
  return XSSFRelation.THEME.getContents(workbookPart);
}

代码示例来源: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.poi/poi-ooxml

ppName = PackagingURIHelper.createPartName(XSSFRelation.VBA_MACROS.getDefaultFileName());
} catch (InvalidFormatException e) {
  throw new POIXMLException(e);

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

/**
 * Generates the relation if required
 */
protected void generateRelationIfNeeded(PackagePart sheetPart) {
  if (_externalRel == null && needsRelationToo()) {
    // Generate the relation
    PackageRelationship rel =
        sheetPart.addExternalRelationship(_location, XSSFRelation.SHEET_HYPERLINKS.getRelation());
    // Update the r:id
    _ctHyperlink.setId(rel.getId());
  }
}

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

protected void beforeDocumentRead() {
  // Ensure it isn't a XLSB file, which we don't support
  if (getCorePart().getContentType().equals(XSSFRelation.XLSB_BINARY_WORKBOOK.getContentType())) {
    throw new XLSBUnsupportedException();
  }
  // Create arrays for parts attached to the workbook itself
  pivotTables = new ArrayList<>();
  pivotCaches = new ArrayList<>();
}

相关文章