import org.apache.poi.hsmf.MAPIMessage;
import org.apache.poi.hsmf.datatypes.AttachmentChunks;
import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
+import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
import org.apache.poi.hssf.extractor.ExcelExtractor;
-import org.apache.poi.hssf.extractor.OldExcelExtractor;
import org.apache.poi.hwpf.OldWordFileFormatException;
import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
}
}
if (poifsDir.hasEntry(OLD_WORKBOOK_DIR_ENTRY_NAME)) {
- throw new IllegalArgumentException("Excel 1-95 file found, call OldExcelExtractor directly");
+ throw new OldExcelFormatException("Old Excel Spreadsheet format (1-95) "
+ + "found. Please call OldExcelExtractor directly for basic text extraction");
}
if (poifsDir.hasEntry("WordDocument")) {
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POIOLE2TextExtractor;
import org.apache.poi.hpbf.extractor.PublisherTextExtractor;
import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
+import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
-import org.apache.xmlbeans.XmlException;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
/**
}
/**
- * #59074 - No supported documents found in the OLE2 stream on
- * a valid Excel file
+ * #59074 - Excel 95 files should give a helpful message, not just
+ * "No supported documents found in the OLE2 stream"
*/
- @Ignore
@Test
public void a() throws Exception {
- POITextExtractor ext = ExtractorFactory.createExtractor(
- POIDataSamples.getSpreadSheetInstance().getFile("59074.xls"));
- assertNotNull(ext);
-
- String text = ext.getText();
- ext.close();
-
-System.err.println(text);
- assertNotNull(text);
- assertTrue(text.contains("test"));
+ try {
+ ExtractorFactory.createExtractor(
+ POIDataSamples.getSpreadSheetInstance().getFile("59074.xls"));
+ fail("Old excel formats not supported via ExtractorFactory");
+ } catch (OldExcelFormatException e) {}
}
}