org.apache.poi.hssf.eventusermodel.HSSFListener Java Examples

The following examples show how to use org.apache.poi.hssf.eventusermodel.HSSFListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EFBiffViewer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void run() throws IOException {
    NPOIFSFileSystem fs   = new NPOIFSFileSystem(new File(file), true);
    try {
        InputStream     din   = BiffViewer.getPOIFSInputStream(fs);
        try {
            HSSFRequest     req   = new HSSFRequest();
    
            req.addListenerForAllRecords(new HSSFListener()
            {
                public void processRecord(Record rec)
                {
                    System.out.println(rec);
                }
            });
            HSSFEventFactory factory = new HSSFEventFactory();
    
            factory.processEvents(req, din);
        } finally {
            din.close();
        }
    } finally {
        fs.close();
    }
}
 
Example #2
Source File: XlsListSheetListener.java    From easyexcel with Apache License 2.0 5 votes vote down vote up
public void execute() {
    MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this);
    HSSFListener formatListener = new FormatTrackingHSSFListener(listener);
    HSSFEventFactory factory = new HSSFEventFactory();
    HSSFRequest request = new HSSFRequest();
    EventWorkbookBuilder.SheetRecordCollectingListener workbookBuildingListener =
        new EventWorkbookBuilder.SheetRecordCollectingListener(formatListener);
    request.addListenerForAllRecords(workbookBuildingListener);
    try {
        factory.processWorkbookEvents(request, xlsReadContext.xlsReadWorkbookHolder().getPoifsFileSystem());
    } catch (IOException e) {
        throw new ExcelAnalysisException(e);
    }
}