Package org.apache.poi.hssf.extractor

Examples of org.apache.poi.hssf.extractor.ExcelExtractor


    //  out from
    for(Iterator entries = poifsDir.getEntries(); entries.hasNext(); ) {
      Entry entry = (Entry)entries.next();
     
      if(entry.getName().equals("Workbook")) {
        return new ExcelExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("WordDocument")) {
        return new WordExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("PowerPoint Document")) {
View Full Code Here


    //  out from
    for(Iterator entries = poifsDir.getEntries(); entries.hasNext(); ) {
      Entry entry = (Entry)entries.next();
     
      if(entry.getName().equals("Workbook")) {
        return new ExcelExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("WordDocument")) {
        return new WordExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("PowerPoint Document")) {
View Full Code Here

          assertEquals("Top Right Cell", s.getRow(0).getCell(255).getStringCellValue());
          assertEquals("Bottom Left Cell", s.getRow(65535).getCell(0).getStringCellValue());
          assertEquals("Bottom Right Cell", s.getRow(65535).getCell(255).getStringCellValue());
         
          // Extract and check
          ExcelExtractor ex = new ExcelExtractor(wb);
          String text = ex.getText();
          assertTrue(text.contains("Top Left Cell"));
          assertTrue(text.contains("Top Right Cell"));
          assertTrue(text.contains("Bottom Left Cell"));
          assertTrue(text.contains("Bottom Right Cell"));
       }
View Full Code Here

 
  public IndexDocument getIndexedDocument(File2Index fileData)
      throws SolrException {
    try {
      POIFSFileSystem fs = new POIFSFileSystem(new ByteArrayInputStream(fileData.data));
      ExcelExtractor extractor = new ExcelExtractor(fs);
      String excelText = extractor.getText();

      return new IndexDocument(fileData.path, excelText, null);
    } catch (IOException e) {
      String msg = "Failed to write to the index";
      log.error(msg, e);
View Full Code Here

                resourceURL = new URL(url);
                is = resourceURL.openStream();
            }

            POIFSFileSystem fs = new POIFSFileSystem(is);
            ExcelExtractor extractor = new ExcelExtractor(fs);
            String excelText = extractor.getText();

            Document document = new Document();
            document.add(new Field("id", id, Field.Store.YES, Field.Index.TOKENIZED));
            document.add(
                    new Field("content", excelText, Field.Store.NO, Field.Index.TOKENIZED));
View Full Code Here

          assertEquals("Top Right Cell", s.getRow(0).getCell(255).getStringCellValue());
          assertEquals("Bottom Left Cell", s.getRow(65535).getCell(0).getStringCellValue());
          assertEquals("Bottom Right Cell", s.getRow(65535).getCell(255).getStringCellValue());
         
          // Extract and check
          ExcelExtractor ex = new ExcelExtractor(wb);
          String text = ex.getText();
          assertTrue(text.contains("Top Left Cell"));
          assertTrue(text.contains("Top Right Cell"));
          assertTrue(text.contains("Bottom Left Cell"));
          assertTrue(text.contains("Bottom Right Cell"));
       }
View Full Code Here

          assertEquals("Top Right Cell", s.getRow(0).getCell(255).getStringCellValue());
          assertEquals("Bottom Left Cell", s.getRow(65535).getCell(0).getStringCellValue());
          assertEquals("Bottom Right Cell", s.getRow(65535).getCell(255).getStringCellValue());
         
          // Extract and check
          ExcelExtractor ex = new ExcelExtractor(wb);
          String text = ex.getText();
          assertTrue(text.contains("Top Left Cell"));
          assertTrue(text.contains("Top Right Cell"));
          assertTrue(text.contains("Bottom Left Cell"));
          assertTrue(text.contains("Bottom Right Cell"));
          ex.close();
       }
    }
View Full Code Here

   */
  public void testComparedToOLE2() throws Exception {
    // A fairly simple file - ooxml
     XSSFEventBasedExcelExtractor ooxmlExtractor = getExtractor("SampleSS.xlsx");

    ExcelExtractor ole2Extractor =
      new ExcelExtractor(HSSFTestDataSamples.openSampleWorkbook("SampleSS.xls"));
   
    POITextExtractor[] extractors =
      new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
    for (int i = 0; i < extractors.length; i++) {
      POITextExtractor extractor = extractors[i];
     
      String text = extractor.getText().replaceAll("[\r\t]", "");
      assertTrue(text.startsWith("First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n"));
      Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL);
      Matcher m = pattern.matcher(text);
      assertTrue(m.matches());     
    }
   
    ole2Extractor.close();
    ooxmlExtractor.close();
  }
View Full Code Here

   */
  public void testComparedToOLE2() throws IOException {
    // A fairly simple file - ooxml
    XSSFExcelExtractor ooxmlExtractor = getExtractor("SampleSS.xlsx");

    ExcelExtractor ole2Extractor =
      new ExcelExtractor(HSSFTestDataSamples.openSampleWorkbook("SampleSS.xls"));
   
    POITextExtractor[] extractors =
      new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
    for (int i = 0; i < extractors.length; i++) {
      POITextExtractor extractor = extractors[i];
     
      String text = extractor.getText().replaceAll("[\r\t]", "");
      assertTrue(text.startsWith("First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n"));
      Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL);
      Matcher m = pattern.matcher(text);
      assertTrue(m.matches());     
    }

    ole2Extractor.close();
    ooxmlExtractor.close();
  }
View Full Code Here

          assertEquals("Top Right Cell", s.getRow(0).getCell(255).getStringCellValue());
          assertEquals("Bottom Left Cell", s.getRow(65535).getCell(0).getStringCellValue());
          assertEquals("Bottom Right Cell", s.getRow(65535).getCell(255).getStringCellValue());
         
          // Extract and check
          ExcelExtractor ex = new ExcelExtractor(wb);
          String text = ex.getText();
          assertTrue(text.contains("Top Left Cell"));
          assertTrue(text.contains("Top Right Cell"));
          assertTrue(text.contains("Bottom Left Cell"));
          assertTrue(text.contains("Bottom Right Cell"));
          ex.close();
       }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.extractor.ExcelExtractor

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.