Package org.apache.poi.hssf.extractor

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


   *  the same file, just saved as xls and xlsx
   */
  public void testComparedToOLE2() throws Exception {
    XSSFExcelExtractor ooxmlExtractor =
      new XSSFExcelExtractor(simpleXLSX.toString());
    ExcelExtractor ole2Extractor =
      new ExcelExtractor(new HSSFWorkbook(
          new FileInputStream(simpleXLS)));
   
    POITextExtractor[] extractors =
      new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
    for (int i = 0; i < extractors.length; i++) {
View Full Code Here

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

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

          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

     
      if(entry.getName().equals("Workbook")) {
         if(getPreferEventExtractor()) {
               return new EventBasedExcelExtractor(poifsDir, fs);
         } else {
            return new ExcelExtractor(poifsDir, fs);
         }
      }
      if(entry.getName().equals("WordDocument")) {
          // Old or new style word document?
          try {
View Full Code Here

     
      if(entry.getName().equals("Workbook")) {
         if(getPreferEventExtractor()) {
               return new EventBasedExcelExtractor(poifsDir, fs);
         } else {
            return new ExcelExtractor(poifsDir, fs);
         }
      }
      if(entry.getName().equals("WordDocument")) {
          // Old or new style word document?
          try {
View Full Code Here

      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

   */
  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];
View Full Code Here

    public void testConstructors() throws Exception {
    POIFSFileSystem fs = new POIFSFileSystem(
        new FileInputStream(new File(dir, "TestUnicode.xls"))
    );
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    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

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.