@Override public DataOut streamParse( final InputStream is, final DataOut dout) throws Exception { _dout = dout; _firstRow = true; try { _fs = new POIFSFileSystem(is); MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); _formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); request.addListenerForAllRecords(_formatListener); factory.processWorkbookEvents(request, _fs); } finally { try { is.close(); } catch (IOException e) { } } return dout; }
/** * Constructs a new MissingRecordAwareHSSFListener, which * will fire processRecord on the supplied child * HSSFListener for all Records, and missing records. * @param listener The HSSFListener to pass records on to */ public MissingRecordAwareHSSFListener(HSSFListener listener) { resetCounts(); childListener = listener; }
/** * 读取 * * @param fs {@link POIFSFileSystem} * @param sheetIndex sheet序号 * @return this * @throws POIException IO异常包装 */ public Excel03SaxReader read(POIFSFileSystem fs, int sheetIndex) throws POIException { this.sheetIndex = sheetIndex; formatListener = new FormatTrackingHSSFListener(new MissingRecordAwareHSSFListener(this)); final HSSFRequest request = new HSSFRequest(); if (isOutputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } final HSSFEventFactory factory = new HSSFEventFactory(); try { factory.processWorkbookEvents(request, fs); } catch (IOException e) { throw new POIException(e); } return this; } // ------------------------------------------------------------------------------ Read end
bof.getType() == BOFRecord.TYPE_WORKSHEET) { resetCounts();
/** * 读取 * * @param fs {@link POIFSFileSystem} * @param sheetIndex sheet序号 * @return this * @throws POIException IO异常包装 */ public Excel03SaxReader read(POIFSFileSystem fs, int sheetIndex) throws POIException { this.sheetIndex = sheetIndex; formatListener = new FormatTrackingHSSFListener(new MissingRecordAwareHSSFListener(this)); final HSSFRequest request = new HSSFRequest(); if (isOutputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } final HSSFEventFactory factory = new HSSFEventFactory(); try { factory.processWorkbookEvents(request, fs); } catch (IOException e) { throw new POIException(e); } return this; } // ------------------------------------------------------------------------------ Read end
/** * Constructs a new MissingRecordAwareHSSFListener, which * will fire processRecord on the supplied child * HSSFListener for all Records, and missing records. * @param listener The HSSFListener to pass records on to */ public MissingRecordAwareHSSFListener(HSSFListener listener) { resetCounts(); childListener = listener; }
@Override public void execute() { init(); MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); if (outputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new EventWorkbookBuilder.SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } try { factory.processWorkbookEvents(request, fs); } catch (IOException e) { throw new ExcelAnalysisException(e); } }
/** * Constructs a new MissingRecordAwareHSSFListener, which * will fire processRecord on the supplied child * HSSFListener for all Records, and missing records. * @param listener The HSSFListener to pass records on to */ public MissingRecordAwareHSSFListener(HSSFListener listener) { resetCounts(); childListener = listener; }
MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener, Locale.UK);
/** * Constructs a new MissingRecordAwareHSSFListener, which * will fire processRecord on the supplied child * HSSFListener for all Records, and missing records. * @param listener The HSSFListener to pass records on to */ public MissingRecordAwareHSSFListener(HSSFListener listener) { resetCounts(); childListener = listener; }
MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener, Locale.UK);
if (bof.getType() == bof.TYPE_WORKBOOK || bof.getType() == bof.TYPE_WORKSHEET) { resetCounts();
/** * 读取 * * @param fs {@link POIFSFileSystem} * @param sheetIndex sheet序号 * @return this * @throws POIException IO异常包装 */ public Excel03SaxReader read(POIFSFileSystem fs, int sheetIndex) throws POIException { this.sheetIndex = sheetIndex; formatListener = new FormatTrackingHSSFListener(new MissingRecordAwareHSSFListener(this)); final HSSFRequest request = new HSSFRequest(); if (isOutputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } final HSSFEventFactory factory = new HSSFEventFactory(); try { factory.processWorkbookEvents(request, fs); } catch (IOException e) { throw new POIException(e); } return this; } // ------------------------------------------------------------------------------ Read end
if (bof.getType() == bof.TYPE_WORKBOOK || bof.getType() == bof.TYPE_WORKSHEET) { resetCounts();
/** * Initiates the processing of the XLS file to CSV */ public List<String> process() throws IOException { MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); if(outputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } factory.processWorkbookEvents(request, fs); return results; }
bof.getType() == BOFRecord.TYPE_WORKSHEET) { resetCounts();
/** * Initiates the processing of the XLS file to CSV */ public void process() throws IOException { MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); if(outputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } factory.processWorkbookEvents(request, fs); }
public void process(InputStream stream) throws IOException { this.fs = new POIFSFileSystem(stream); MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); if (outputFormulaValues) { request.addListenerForAllRecords(formatListener); } else { workbookBuildingListener = new SheetRecordCollectingListener(formatListener); request.addListenerForAllRecords(workbookBuildingListener); } factory.processWorkbookEvents(request, fs); }
HSSFRequest req = new HSSFRequest(); HSSFEventParser parser = new HSSFEventParser(this.sheetNameList,this.useDataFormatter,this.spreadSheetCellDAOCache,this.sheets); SheetRecordCollectingListener listener = new SheetRecordCollectingListener(new MissingRecordAwareHSSFListener(parser)); parser.setSheetRecordCollectingListener(listener); req.addListenerForAllRecords(listener);