--- ExcelExtractor.java.orig 2008-09-23 17:35:31 +0000 +++ ExcelExtractor.java 2009-01-22 23:59:00 +0000 @@ -18,6 +18,8 @@ package org.apache.poi.hssf.extractor; import java.io.IOException; +import java.io.InputStream; +import java.io.FileInputStream; import org.apache.poi.POIOLE2TextExtractor; import org.apache.poi.ss.usermodel.HeaderFooter; @@ -51,13 +53,35 @@ super(wb); this.wb = wb; } + + public ExcelExtractor(String fileName) throws IOException { + this(new FileInputStream(fileName)); + } + + public ExcelExtractor(InputStream iStream) throws IOException { + this(new POIFSFileSystem(iStream)); + } + public ExcelExtractor(POIFSFileSystem fs) throws IOException { this(fs.getRoot(), fs); } public ExcelExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException { this(new HSSFWorkbook(dir, fs, true)); } - + + /** + * Command line extractor. + */ + public static void main(String[] args) throws Exception { + if(args.length < 1) { + System.err.println("Use:"); + System.err.println(" java org.apache.poi.hssf.extractor.ExcelExtractor "); + System.exit(1); + } + + ExcelExtractor extractor = new ExcelExtractor(args[0]); + System.out.println(extractor.getText()); + } /** * Should sheet names be included? Default is true