Examples of OPCPackage


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

    assertTrue(text.contains("LastModifiedBy = Yury Batrakov"));
    assertTrue(cText.contains("LastModifiedBy = Yury Batrakov"));
  }
 
  public void testExtended() throws Exception {
    OPCPackage pkg = OPCPackage.open(
        (new File(dirname, "ExcelWithAttachments.xlsx")).toString()
    );
    XSSFWorkbook wb = new XSSFWorkbook(pkg);
   
    POIXMLPropertiesTextExtractor ext = new POIXMLPropertiesTextExtractor(wb);
View Full Code Here

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

    assertTrue(sampleFile.exists());
    assertTrue(complexFile.exists());
  }

  public void testContainsMainContentType() throws Exception {
    OPCPackage pack = POIXMLDocument.openPackage(sampleFile.toString());
   
    boolean found = false;
    for(PackagePart part : pack.getParts()) {
      if(part.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
        found = true;
      }
      System.out.println(part);
    }
View Full Code Here

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

*/
public class XSSFTestDataSamples {
  public static final XSSFWorkbook openSampleWorkbook(String sampleName) {
    InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleName);
    try {
      OPCPackage pkg = OPCPackage.open(is);
      return new XSSFWorkbook(pkg);
    } catch (InvalidFormatException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
      throw new RuntimeException(e);
View Full Code Here

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

                File tmp = File.createTempFile("poi-ooxml-", ".xlsx");
                tmp.deleteOnExit();
                FileOutputStream out = new FileOutputStream(tmp);
                wb.write(out);
                out.close();
                OPCPackage pkg = OPCPackage.open(tmp.getAbsolutePath());
          result = new XSSFWorkbook(pkg);
        } else {
          throw new RuntimeException("Unexpected workbook type ("
              + wb.getClass().getName() + ")");
        }
View Full Code Here

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

     */
    public static OPCPackage clone(OPCPackage pkg, File file) throws OpenXML4JException, IOException {

        String path = file.getAbsolutePath();

        OPCPackage dest = OPCPackage.create(path);
        PackageRelationshipCollection rels = pkg.getRelationships();
        for (PackageRelationship rel : rels) {
            PackagePart part = pkg.getPart(rel);
            PackagePart part_tgt;
            if (rel.getRelationshipType().equals(PackageRelationshipTypes.CORE_PROPERTIES)) {
                copyProperties(pkg.getPackageProperties(), dest.getPackageProperties());
                continue;
            } else {
                dest.addRelationship(part.getPartName(), rel.getTargetMode(), rel.getRelationshipType());
                part_tgt = dest.createPart(part.getPartName(), part.getContentType());
            }

            OutputStream out = part_tgt.getOutputStream();
            IOUtils.copy(part.getInputStream(), out);
            out.close();

            if(part.hasRelationships()) {
                copy(pkg, part, dest, part_tgt);
            }
        }
        dest.close();

        //the temp file will be deleted when JVM terminates
        new File(path).deleteOnExit();
        return OPCPackage.open(path);
    }
View Full Code Here

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

        File.separator + "sample.pptx"
    ).toString();
  }

  public void testContainsMainContentType() throws Exception {
    OPCPackage pack = POIXMLDocument.openPackage(sampleFile);
   
    boolean found = false;
    for(PackagePart part : pack.getParts()) {
      if(part.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
        found = true;
      }
      //System.out.println(part);
    }
View Full Code Here

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

      );
  }
   
    public void testGetBits() throws Exception {
      File f = new File(dirName, "SampleSS.xlsx");
      OPCPackage pkg = OPCPackage.open(f.toString());
     
      XSSFReader r = new XSSFReader(pkg);
     
      assertNotNull(r.getWorkbookData());
      assertNotNull(r.getSharedStringsData());
View Full Code Here

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

      assertNotNull(r.getStylesTable());
    }
   
    public void testStyles() throws Exception {
      File f = new File(dirName, "SampleSS.xlsx");
      OPCPackage pkg = OPCPackage.open(f.toString());
     
      XSSFReader r = new XSSFReader(pkg);
     
      assertEquals(3, r.getStylesTable().getFonts().size());
      assertEquals(0, r.getStylesTable()._getNumberFormatSize());
View Full Code Here

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

      assertEquals(0, r.getStylesTable()._getNumberFormatSize());
    }
   
    public void testStrings() throws Exception {
      File f = new File(dirName, "SampleSS.xlsx");
      OPCPackage pkg = OPCPackage.open(f.toString());
     
      XSSFReader r = new XSSFReader(pkg);
     
      assertEquals(11, r.getSharedStringsTable().getItems().size());
      assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
View Full Code Here

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

      assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
    }
   
    public void testSheets() throws Exception {
      File f = new File(dirName, "SampleSS.xlsx");
      OPCPackage pkg = OPCPackage.open(f.toString());
     
      XSSFReader r = new XSSFReader(pkg);
      byte[] data = new byte[4096];
     
      // By r:id
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.