List of usage examples for org.apache.poi.hssf.eventusermodel EventWorkbookBuilder.SheetRecordCollectingListener EventWorkbookBuilder.SheetRecordCollectingListener
public SheetRecordCollectingListener(HSSFListener childListener)
From source file:com.googlecode.sqlsheet.stream.XlsSheetIterator.java
License:Apache License
/** * Initiates the processing/* w ww . ja v a 2s . com*/ * - position stream to the right sheet * - extracts columns * - extracts first row */ public void postConstruct() throws SQLException { try { boundSheetRecords = new ArrayList(); sheetIndex = -1; inRequiredSheet = false; outputFormulaValues = true; fileSystem = new NPOIFSFileSystem(getFileName().openStream()); recordStream = new RecordFactoryInputStream(fileSystem.getRoot().createDocumentInputStream("Workbook"), false); MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); requestPublic = new PublicMorozoffHSSFRequest(); if (outputFormulaValues) { requestPublic.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new EventWorkbookBuilder.SheetRecordCollectingListener(formatListener); requestPublic.addListenerForAllRecords(workbookBuildingListener); } // Process each record as they come in till we get to the right sheet while (!inRequiredSheet) { Record r = recordStream.nextRecord(); if (r == null) { break; } try { short userCode = requestPublic.processRecord(r); if (userCode != 0) { break; } } catch (HSSFUserException e) { throw new RuntimeException(e.getMessage(), e); } } //Flush rows counter setCurrentSheetRowIndex(0L); //Fill current row processNextRecords(); } catch (IOException e) { throw new SQLException(e.getMessage(), e); } }