Package org.apache.poi.poifs.filesystem

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


  }
 
  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


        // Force the document stream to a (possibly temporary) file
        // so we don't modify the current position of the stream
        FileChannel channel = stream.getFileChannel();

        try {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(channel);

            // Optimize a possible later parsing process by keeping
            // a reference to the already opened POI file system
            stream.setOpenContainer(fs);

            return getTopLevelNames(fs.getRoot());
        } catch (IOException e) {
            // Parse error in POI, so we don't know the file type
            return Collections.emptySet();
        } catch (RuntimeException e) {
            // Another problem in POI
View Full Code Here

    @Test
    public void bug57080() throws Exception {
        // the test file contains a wrong ole entry size, produced by extenxls
        // the fix limits the available size and tries to read all entries
        File f = POIDataSamples.getPOIFSInstance().getFile("extenxls_pwd123.xlsx");
        NPOIFSFileSystem fs = new NPOIFSFileSystem(f, true);
        EncryptionInfo info = new EncryptionInfo(fs);
        Decryptor d = Decryptor.getInstance(info);
        d.verifyPassword("pwd123");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ZipInputStream zis = new ZipInputStream(d.getDataStream(fs));
        ZipEntry ze;
        while ((ze = zis.getNextEntry()) != null) {
            bos.reset();
            IOUtils.copy(zis, bos);
            assertEquals(ze.getSize(), bos.size());
        }
       
        zis.close();
        fs.close();
    }
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 bug51461() 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 bug51535() 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

     */
    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

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.