Package org.apache.poi.poifs.filesystem

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


    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

     */
    public void testDifferentPOIFS() throws Exception {
       // Open the two filesystems
       DirectoryNode[] files = new DirectoryNode[2];
       files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))).getRoot();
       files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))).getRoot();
      
       // Open without preserving nodes
       for(DirectoryNode dir : files) {
          HSSFWorkbook workbook = new HSSFWorkbook(dir, false);
          HSSFSheet sheet = workbook.getSheetAt(0);
View Full Code Here

   
    public void testWordDocEmbeddedInXls() throws IOException {
       // Open the two filesystems
       DirectoryNode[] files = new DirectoryNode[2];
       files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))).getRoot();
       files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))).getRoot();
      
       // Check the embedded parts
       for(DirectoryNode root : files) {
          HSSFWorkbook hw = new HSSFWorkbook(root, true);
          List<HSSFObjectData> objects = hw.getAllEmbeddedObjects();
View Full Code Here

     *  again (via POIFS) and have it be valid
     * @throws IOException
     */
    public void testWriteWorkbookFromNPOIFS() throws IOException {
       InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls");
       NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
      
       // Start as NPOIFS
       HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
       assertEquals(3, wb.getNumberOfSheets());
       assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
      
       // Will switch to POIFS
       wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
View Full Code Here

      ext = new PublisherTextExtractor(docOPOIFS);
      assertEquals( SAMPLE_TEXT, ext.getText() );

      // And with NPOIFS
      HPBFDocument docNPOIFS = new HPBFDocument(
            new NPOIFSFileSystem(sample)
      );
    ext = new PublisherTextExtractor(docNPOIFS);
    assertEquals( SAMPLE_TEXT, ext.getText() );

   
View Full Code Here

       POIDataSamples docTests = POIDataSamples.getDocumentInstance();
      
       // Open the two filesystems
       DirectoryNode[] files = new DirectoryNode[2];
       files[0] = (new POIFSFileSystem(docTests.openResourceAsStream("test2.doc"))).getRoot();
       files[1] = (new NPOIFSFileSystem(docTests.getFile("test2.doc"))).getRoot();
      
       // Open directly
       for(DirectoryNode dir : files) {
          WordExtractor extractor = new WordExtractor(dir, null);
          assertEquals(p_text1_block, extractor.getText());
View Full Code Here

     */
    public void testDifferentPOIFS() throws Exception {
       // Open the two filesystems
       DirectoryNode[] files = new DirectoryNode[2];
       files[0] = (new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"))).getRoot();
       files[1] = (new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"))).getRoot();
      
       // Open directly
       for(DirectoryNode dir : files) {
          PowerPointExtractor extractor = new PowerPointExtractor(dir, null);
          assertEquals(expectText, extractor.getText());
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

         }
      }
   }

   public static void viewFile(final String filename, boolean withSizes) throws IOException {
      NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(filename));
      displayDirectory(fs.getRoot(), "", withSizes);
   }
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.