Package org.openxml4j.opc

Examples of org.openxml4j.opc.PackageRelationship


      return null;
    }
    if(rels.size() > 1) {
      throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
    }
    PackageRelationship rel = rels.getRelationship(0);
    return getPackagePart(rel);
  }
View Full Code Here


      return null;
    }
    if(rels.size() > 1) {
      throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
    }
    PackageRelationship rel = rels.getRelationship(0);
    return getPackagePart(rel);
  }
View Full Code Here

   *  id. This will normally come from a r:id attribute
   *  on part of the base document.
   * @param partId The r:id pointing to the other PackagePart
   */
  protected PackagePart getRelatedPackagePart(String partId) {
    PackageRelationship rel =
      basePart.getRelationship(partId);
    return getPackagePart(rel);
  }
View Full Code Here

   * Generates the relation if required
   */
  protected void generateRelationIfNeeded(PackagePart sheetPart) {
    if(needsRelationToo()) {
      // Generate the relation
      PackageRelationship rel =
        sheetPart.addExternalRelationship(location, XSSFWorkbook.SHEET_HYPERLINKS.getRelation());
     
      // Update the r:id
      ctHyperlink.setId(rel.getId());
    }
  }
View Full Code Here

    // TODO: make me optional/separated in private function
    try  {
      Iterator <PackageRelationship> relIter =
        getCorePart().getRelationshipsByType(HYPERLINK_RELATION_TYPE).iterator();
      while(relIter.hasNext()) {
        PackageRelationship rel = relIter.next();
        hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
      }
    } catch(Exception e) {
      throw new OpenXML4JException(e.getLocalizedMessage());
    }
View Full Code Here

   
    protected POIXMLDocument(Package pkg) throws IOException {
      try {
        this.pkg = pkg;
       
          PackageRelationship coreDocRelationship = this.pkg.getRelationshipsByType(
                  PackageRelationshipTypes.CORE_DOCUMENT).getRelationship(0);
     
          // Get core part
          this.corePart = this.pkg.getPart(coreDocRelationship);
View Full Code Here

      return null;
    }
    if(rels.size() > 1) {
      throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
    }
    PackageRelationship rel = rels.getRelationship(0);
    return getTargetPart(rel);
  }
View Full Code Here

   * Creates a new XSSFReader, for the given package
   */
  public XSSFReader(Package pkg) throws IOException, OpenXML4JException {
    this.pkg = pkg;
   
        PackageRelationship coreDocRelationship = this.pkg.getRelationshipsByType(
                PackageRelationshipTypes.CORE_DOCUMENT).getRelationship(0);
   
        // Get the part that holds the workbook
        workbookPart = this.pkg.getPart(coreDocRelationship);
  }
View Full Code Here

   * Returns an InputStream to read the contents of the
   *  specified Sheet.
   * @param relId The relationId of the sheet, from a r:id on the workbook
   */
  public InputStream getSheet(String relId) throws IOException, InvalidFormatException {
        PackageRelationship rel = workbookPart.getRelationship(relId);
        if(rel == null) {
          throw new IllegalArgumentException("No Sheet found with r:id " + relId);
        }
       
        PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
        PackagePart sheet = pkg.getPart(relName);
        if(sheet == null) {
          throw new IllegalArgumentException("No data found for Sheet with r:id " + relId);
        }
        return sheet.getInputStream();
View Full Code Here

    public boolean hasNext() {
      return sheetRels.hasNext();
    }

    public InputStream next() {
      PackageRelationship sheet = sheetRels.next();
      try {
            PackagePartName relName = PackagingURIHelper.createPartName(sheet.getTargetURI());
        PackagePart sheetPkg = pkg.getPart(relName);
        return sheetPkg.getInputStream();
      } catch(IOException e) {
        throw new RuntimeException(e);
      } catch(InvalidFormatException ife) {
View Full Code Here

TOP

Related Classes of org.openxml4j.opc.PackageRelationship

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.