Examples of ExcelExtractor


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

      fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
      wb = new HSSFWorkbook(fs);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    ExcelExtractor excelExt = new ExcelExtractor(wb);

    String fsText = (new HPSFPropertiesExtractor(fs)).getText();
    String hwText = (new HPSFPropertiesExtractor(wb)).getText();
    String eeText = (new HPSFPropertiesExtractor(excelExt)).getText();
View Full Code Here

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

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

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

        // out from
        if (poifsDir.hasEntry("Workbook")) {
            if (getPreferEventExtractor()) {
                return new EventBasedExcelExtractor(poifsDir);
            }
            return new ExcelExtractor(poifsDir);
        }

        if (poifsDir.hasEntry("WordDocument")) {
            // Old or new style word document?
            try {
View Full Code Here

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

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

   */
  public void testComparedToOLE2() {
    // 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];
View Full Code Here

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

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

            );
      wb = new HSSFWorkbook(fs);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    ExcelExtractor excelExt = new ExcelExtractor(wb);

    String fsText = (new HPSFPropertiesExtractor(fs)).getText();
    String hwText = (new HPSFPropertiesExtractor(wb)).getText();
    String eeText = (new HPSFPropertiesExtractor(excelExt)).getText();
View Full Code Here

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

     
      if(entry.getName().equals("Workbook")) {
         if(getPreferEventExtractor()) {
               return new EventBasedExcelExtractor(poifsDir, fs);
         } else {
            return new ExcelExtractor(poifsDir, fs);
         }
      }
      if(entry.getName().equals("WordDocument")) {
        return new WordExtractor(poifsDir, fs);
      }
View Full Code Here

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

    public Reader extractText(InputStream stream,
                              String type,
                              String encoding) throws IOException {
        try {
            POIFSFileSystem fs = new POIFSFileSystem(stream);
            return new StringReader(new ExcelExtractor(fs).getText());
        } catch (RuntimeException e) {
            logger.warn("Failed to extract Excel text content", e);
            return new StringReader("");
        } finally {
            stream.close();
View Full Code Here

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

   */
  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
TOP
Copyright © 2018 www.massapi.com. 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.