Package org.apache.poi.poifs.filesystem

Examples of org.apache.poi.poifs.filesystem.DirectoryNode


    String filename = pdirname + "/excel_with_embeded.xls";
    POIFSFileSystem fs = new POIFSFileSystem(
        new FileInputStream(filename)
    );
   
    DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5");
    DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4");
   
    HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
    HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);
   
    ExcelExtractor exA = new ExcelExtractor(wbA);
View Full Code Here


  /**
   * @param path  the path to the part, eg Contents or Quill, QuillSub, CONTENTS
   */
  public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
    
    DirectoryNode dir = getDir(path, baseDir);
    String name = path[path.length-1];
   
    DocumentEntry docProps;
    try {
      docProps = (DocumentEntry)dir.getEntry(name);
    } catch (FileNotFoundException e) {
      throw new IllegalArgumentException("File invalid - failed to find document entry '"
          + name + "'");
    }

    // Grab the data from the part stream
    data = new byte[docProps.getSize()];
    dir.createDocumentInputStream(name).read(data);
  }
View Full Code Here

    // Grab the data from the part stream
    data = new byte[docProps.getSize()];
    dir.createDocumentInputStream(name).read(data);
  }
  private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
    DirectoryNode dir = baseDir;
    for(int i=0; i<path.length-1; i++) {
      try {
        dir = (DirectoryNode)dir.getEntry(path[i]);
      } catch (FileNotFoundException e) {
        throw new IllegalArgumentException("File invalid - failed to find directory entry '"
            + path[i] + "'");
      }
    }
View Full Code Here

 
  public void writeOut(DirectoryNode baseDir) throws IOException {
    String[] path = getPath();
   
    // Ensure that all parent directories exist
    DirectoryNode dir = baseDir;
    for(int i=0; i<path.length-1; i++) {
      try {
        dir = (DirectoryNode)dir.getEntry(path[i]);
      } catch(FileNotFoundException e) {
        dir.createDirectory(path[i]);
      }
    }
   
    // Update the byte array with the latest data
    generateData();
   
    // Write out
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    dir.createDocument(path[path.length-1], bais);
  }
View Full Code Here

  /**
   * Dump out the escher parts of the file.
   * Escher -> EscherStm and EscherDelayStm
   */
  public void dumpEscher() throws IOException {
    DirectoryNode escherDir = (DirectoryNode)
      fs.getRoot().getEntry("Escher");
   
    dumpEscherStm(escherDir);
    dumpEscherDelayStm(escherDir);
  }
View Full Code Here

  protected void dump001CompObj(DirectoryNode dir) {
    // TODO
  }
 
  public void dumpQuill() throws IOException {
    DirectoryNode quillDir = (DirectoryNode)
      fs.getRoot().getEntry("Quill");
    DirectoryNode quillSubDir = (DirectoryNode)
      quillDir.getEntry("QuillSub");

    dump001CompObj(quillSubDir);
    dumpCONTENTSraw(quillSubDir);
    dumpCONTENTSguessed(quillSubDir);
View Full Code Here

    public void testExtractFromEmbeded() throws Exception {
      POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename3));
      HWPFDocument doc;
      WordExtractor extractor3;
     
      DirectoryNode dirA = (DirectoryNode)
      fs.getRoot().getEntry("MBD0000A3B7");
      DirectoryNode dirB = (DirectoryNode)
        fs.getRoot().getEntry("MBD0000A3B2");
     
      // Should have WordDocument and 1Table
      assertNotNull(dirA.getEntry("1Table"));
      assertNotNull(dirA.getEntry("WordDocument"));
     
      assertNotNull(dirB.getEntry("1Table"));
      assertNotNull(dirB.getEntry("WordDocument"));
     
      // Check each in turn
      doc = new HWPFDocument(dirA, fs);
      extractor3 = new WordExtractor(doc);
   
View Full Code Here

  public void testExtractFromEmbeded() throws Exception {
    POIFSFileSystem fs = new POIFSFileSystem(POIDataSamples.getSpreadSheetInstance().openResourceAsStream(filename3));
    HWPFDocument doc;
    WordExtractor extractor3;

    DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B7");
    DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B2");

    // Should have WordDocument and 1Table
    assertNotNull(dirA.getEntry("1Table"));
    assertNotNull(dirA.getEntry("WordDocument"));

    assertNotNull(dirB.getEntry("1Table"));
    assertNotNull(dirB.getEntry("WordDocument"));

    // Check each in turn
    doc = new HWPFDocument(dirA, fs);
    extractor3 = new WordExtractor(doc);
View Full Code Here

        HSSFWorkbook workbook = new HSSFWorkbook(fs);
        for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
            //the OLE2 Class Name of the object
            String oleName = obj.getOLE2ClassName();
            if (oleName.equals("Worksheet")) {
                DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(dn, fs, false);
                //System.out.println(entry.getName() + ": " + embeddedWorkbook.getNumberOfSheets());
            } else if (oleName.equals("Document")) {
                DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                HWPFDocument embeddedWordDocument = new HWPFDocument(dn);
                //System.out.println(entry.getName() + ": " + embeddedWordDocument.getRange().text());
            else if (oleName.equals("Presentation")) {
                DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                SlideShow embeddedPowerPointDocument = new SlideShow(new HSLFSlideShow(dn));
                //System.out.println(entry.getName() + ": " + embeddedPowerPointDocument.getSlides().length);
            } else {
                if(obj.hasDirectoryEntry()){
                    // The DirectoryEntry is a DocumentNode. Examine its entries to find out what it is
                    DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                    for (Iterator entries = dn.getEntries(); entries.hasNext();) {
                        Entry entry = (Entry) entries.next();
                        //System.out.println(oleName + "." + entry.getName());
                    }
                } else {
                    // There is no DirectoryEntry
View Full Code Here

  public void testWithEmbeded() throws Exception {
    POIFSFileSystem fs = new POIFSFileSystem(
      POIDataSamples.getDocumentInstance().openResourceAsStream("word_with_embeded.doc")
    );

    DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntry("ObjectPool");
    DirectoryNode dirA = (DirectoryNode) objPool.getEntry("_1269427460");
    DirectoryNode dirB = (DirectoryNode) objPool.getEntry("_1269427461");

    HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
    HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);

    ExcelExtractor exA = new ExcelExtractor(wbA);
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.filesystem.DirectoryNode

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.