Examples of PackagePart


Examples of org.apache.poi.openxml4j.opc.PackagePart

        map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
        map.put("urn:schemas-microsoft-com:office:word", "w10");
        map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
        map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
        xmlOptions.setSaveSuggestedPrefixes(map);
        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        super._getHdrFtr().save(out, xmlOptions);
        out.close();
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

    //  feature of the file format yet
    this.doc = doc;
    for(int i=0; i<sectPr.sizeOfHeaderReferenceArray(); i++) {
      // Get the header
      CTHdrFtrRef ref = sectPr.getHeaderReferenceArray(i);
      PackagePart hdrPart = doc.getPartById(ref.getId());
      HdrDocument hdrDoc = HdrDocument.Factory.parse(hdrPart.getInputStream());
      CTHdrFtr hdrFtr = hdrDoc.getHdr();
      XWPFHeader hdr = new XWPFHeader(doc, hdrFtr);

      // Assign it
      Enum type = ref.getType();
      assignHeader(hdr, type);
    }
    for(int i=0; i<sectPr.sizeOfFooterReferenceArray(); i++) {
      // Get the footer
      CTHdrFtrRef ref = sectPr.getFooterReferenceArray(i);
      PackagePart ftrPart = doc.getPartById(ref.getId());
      XWPFFooter ftr = new XWPFFooter(doc,
          FtrDocument.Factory.parse(ftrPart.getInputStream()).getFtr());

      // Assign it
      Enum type = ref.getType();
      assignFooter(ftr, type);
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

        }
    }

    @Override
    protected void commit() throws IOException {
        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        write(out);
        out.close();
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm");
        OPCPackage pkg = wb.getPackage();
        assertTrue(wb.isMacroEnabled());

        // Check the various macro related bits can be found
        PackagePart vba = pkg.getPart(
                PackagingURIHelper.createPartName("/xl/vbaProject.bin")
        );
        assertNotNull(vba);
        // And the drawing bit
        PackagePart drw = pkg.getPart(
                PackagingURIHelper.createPartName("/xl/drawings/vmlDrawing1.vml")
        );
        assertNotNull(drw);

View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

  private void test(POIXMLDocument doc, int expectedCount) throws Exception {
    assertNotNull(doc.getAllEmbedds());
    assertEquals(expectedCount, doc.getAllEmbedds().size());

    for(int i=0; i<doc.getAllEmbedds().size(); i++) {
      PackagePart pp = doc.getAllEmbedds().get(i);
      assertNotNull(pp);
     
      byte[] b = IOUtils.toByteArray(pp.getInputStream());
      assertTrue(b.length > 0);
    }
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

      pkg.getRelationshipsByType(CORE_DOCUMENT_REL);
    if(core.size() != 1) {
      throw new IllegalArgumentException("Invalid OOXML Package received - expected 1 core document, found " + core.size());
    }
   
    PackagePart corePart = pkg.getPart(core.getRelationship(0));
    if(corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType())) {
      return new XSSFExcelExtractor(pkg);
    }
    if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
      return new XWPFWordExtractor(pkg);
    }
    if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
      return new XSLFPowerPointExtractor(pkg);
    }
    throw new IllegalArgumentException("No supported documents found in the OOXML package");
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

    doc.save(out, options);
  }

    @Override
    protected void commit() throws IOException {
        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        writeTo(out);
        out.close();
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

        xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook"));
        Map<String, String> map = new HashMap<String, String>();
        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
        xmlOptions.setSaveSuggestedPrefixes(map);

        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        workbook.save(out, xmlOptions);
        out.close();
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

    workbook.write(out);
    out.close();
   
    // Check the package contains what we'd expect it to
    OPCPackage pkg = OPCPackage.open(file.toString());
    PackagePart wbRelPart =
      pkg.getPart(PackagingURIHelper.createPartName("/xl/_rels/workbook.xml.rels"));
    assertNotNull(wbRelPart);
    assertTrue(wbRelPart.isRelationshipPart());
    assertEquals(ContentTypes.RELATIONSHIPS_PART, wbRelPart.getContentType());
   
    PackagePart wbPart =
      pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
    // Links to the three sheets, shared strings and styles
    assertTrue(wbPart.hasRelationships());
    assertEquals(5, wbPart.getRelationships().size());
   
    // Load back the XSSFWorkbook
    workbook = new XSSFWorkbook(pkg);
    assertEquals(3, workbook.getNumberOfSheets());
    assertNotNull(workbook.getSheetAt(0));
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackagePart

    assertNotNull(workbook.getSharedStringSource());
    assertNotNull(workbook.getStylesSource());
   
    // And check a few low level bits too
    OPCPackage pkg = OPCPackage.open(HSSFTestDataSamples.openSampleFileStream("Formatting.xlsx"));
    PackagePart wbPart =
      pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
   
    // Links to the three sheets, shared, styles and themes
    assertTrue(wbPart.hasRelationships());
    assertEquals(6, wbPart.getRelationships().size());

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.