Package org.apache.poi.poifs.filesystem

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


        xhtml.startDocument();

        final DirectoryNode root;
        TikaInputStream tstream = TikaInputStream.cast(stream);
        if (tstream == null) {
            root = new NPOIFSFileSystem(new CloseShieldInputStream(stream)).getRoot();
        } else {
            final Object container = tstream.getOpenContainer();
            if (container instanceof NPOIFSFileSystem) {
                root = ((NPOIFSFileSystem) container).getRoot();
            } else if (container instanceof DirectoryNode) {
                root = (DirectoryNode) container;
            } else if (tstream.hasFile()) {
                root = new NPOIFSFileSystem(tstream.getFileChannel()).getRoot();
            } else {
                root = new NPOIFSFileSystem(new CloseShieldInputStream(tstream)).getRoot();
            }
        }
        parse(root, context, metadata, xhtml);
        xhtml.endDocument();
    }
View Full Code Here


    }
   
    @Test(expected=EncryptedDocumentException.class)
    public void bug55692_npoifs() throws Exception {
        // Via a NPOIFSFileSystem
        NPOIFSFileSystem fsNP = new NPOIFSFileSystem(POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
        WorkbookFactory.create(fsNP);
    }
View Full Code Here

     */
    public void test51671() throws Exception
    {
        InputStream is = POIDataSamples.getDocumentInstance()
                .openResourceAsStream( "empty.doc" );
        NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem( is );
        HWPFDocument hwpfDocument = new HWPFDocument(
                npoifsFileSystem.getRoot() );
        hwpfDocument.write( new ByteArrayOutputStream() );
    }
View Full Code Here

    public void test51461() throws Exception {
       byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls");
      
       HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
             new ByteArrayInputStream(data)).getRoot(), false);
       HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(
             new ByteArrayInputStream(data)).getRoot(), false);
      
       assertEquals(2, wbPOIFS.getNumberOfSheets());
       assertEquals(2, wbNPOIFS.getNumberOfSheets());
    }
View Full Code Here

    public void test51535() throws Exception {
       byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51535.xls");
      
       HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
             new ByteArrayInputStream(data)).getRoot(), false);
       HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(
             new ByteArrayInputStream(data)).getRoot(), false);
      
       for(HSSFWorkbook wb : new HSSFWorkbook[] {wbPOIFS, wbNPOIFS}) {
          assertEquals(3, wb.getNumberOfSheets());
         
View Full Code Here

        WorkbookFactory.create(fsP);
        fail("Should've raised a EncryptedDocumentException error");
      } catch (EncryptedDocumentException e) {}

      // Via a NPOIFSFileSystem
      NPOIFSFileSystem fsNP = new NPOIFSFileSystem(inpC);
      try {
        WorkbookFactory.create(fsNP);
        fail("Should've raised a EncryptedDocumentException error");
      } catch (EncryptedDocumentException e) {}
    }
View Full Code Here

        WorkbookFactory.create(fsP);
        fail("Should've raised a EncryptedDocumentException error");
      } catch (EncryptedDocumentException e) {}

      // Via a NPOIFSFileSystem
      NPOIFSFileSystem fsNP = new NPOIFSFileSystem(inpC);
      try {
        WorkbookFactory.create(fsNP);
        fail("Should've raised a EncryptedDocumentException error");
      } catch (EncryptedDocumentException e) {}
    }
View Full Code Here

        if (! file.exists()) {
            throw new FileNotFoundException(file.toString());
        }

        try {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(file);
            return new HSSFWorkbook(fs.getRoot(), true);
        } catch(OfficeXmlFileException e) {
            OPCPackage pkg = OPCPackage.open(file);
            return new XSSFWorkbook(pkg);
        }
    }
View Full Code Here

    }

    public static void main(String[] args) throws IOException {
        for (String file : args) {
            HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(
                    new NPOIFSFileSystem(new File(file)));
            System.out.println(ext.getText());
        }
    }
View Full Code Here

     *  Encryption options, and no cspname section. See bug 53475
     */
    @Test
    public void bug53475NoCSPName() throws Exception {
        File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-solrcell.docx");
        NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);

        // Check the encryption details
        EncryptionInfo info = new EncryptionInfo(filesystem);
        assertEquals(128, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm());
View Full Code Here

TOP

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

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.