Java Code Examples for org.apache.poi.hssf.eventusermodel.HSSFEventFactory

The following examples show how to use org.apache.poi.hssf.eventusermodel.HSSFEventFactory. These examples are extracted from open source projects. 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 Project: easyexcel   Source File: XlsSaxAnalyser.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void execute() {
    XlsReadWorkbookHolder xlsReadWorkbookHolder = xlsReadContext.xlsReadWorkbookHolder();
    MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this);
    xlsReadWorkbookHolder.setFormatTrackingHSSFListener(new FormatTrackingHSSFListener(listener));
    EventWorkbookBuilder.SheetRecordCollectingListener workbookBuildingListener =
        new EventWorkbookBuilder.SheetRecordCollectingListener(
            xlsReadWorkbookHolder.getFormatTrackingHSSFListener());
    xlsReadWorkbookHolder.setHssfWorkbook(workbookBuildingListener.getStubHSSFWorkbook());
    HSSFEventFactory factory = new HSSFEventFactory();
    HSSFRequest request = new HSSFRequest();
    request.addListenerForAllRecords(xlsReadWorkbookHolder.getFormatTrackingHSSFListener());
    try {
        factory.processWorkbookEvents(request, xlsReadWorkbookHolder.getPoifsFileSystem());
    } catch (IOException e) {
        throw new ExcelAnalysisException(e);
    }
}
 
Example 2
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	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);
	//数据读取完成
	
}
 
Example 3
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
	
}
 
Example 4
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	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);
	//数据读取完成
	
}
 
Example 5
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
	
}
 
Example 6
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	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);
	//数据读取完成
	
}
 
Example 7
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
	
}
 
Example 8
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	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);
	//数据读取完成
	
}
 
Example 9
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
	
}
 
Example 10
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	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);
	//数据读取完成
	
}
 
Example 11
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
	
}
 
Example 12
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process(String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem(new FileInputStream(fileName));
	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);
	//数据读取完成
}
 
Example 13
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
}
 
Example 14
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process(String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem(new FileInputStream(fileName));
	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);
	//数据读取完成
}
 
Example 15
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	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);
	//数据读取完成
}
 
Example 16
Source Project: lams   Source File: EFBiffViewer.java    License: 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 17
Source Project: myexcel   Source File: HSSFSaxReadHandler.java    License: Apache License 2.0 6 votes vote down vote up
public void process() throws IOException {
    long startTime = System.currentTimeMillis();
    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);
    }

    factory.processWorkbookEvents(request, fs);
    log.info("Sax import takes {} ms", System.currentTimeMillis() - startTime);
}
 
Example 18
Source Project: azeroth   Source File: XLS2CSV.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source Project: bdf3   Source File: XLS2CSV.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    close();
}
 
Example 20
Source Project: jeesuite-libs   Source File: XLS2CSV.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 21
Source Project: easyexcel   Source File: XlsListSheetListener.java    License: 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);
    }
}
 
Example 22
private TextListener triggerExtraction() throws IOException {
    TextListener tl = new TextListener();
    FormatTrackingHSSFListener ft = new FormatTrackingHSSFListener(tl);
    tl._ft = ft;

    // Register and process
    HSSFEventFactory factory = new HSSFEventFactory();
    HSSFRequest request = new HSSFRequest();
    request.addListenerForAllRecords(ft);

    factory.processWorkbookEvents(request, _dir);

    return tl;
}
 
Example 23
Source Project: easyexcel   Source File: Default03RecordHandlerContext.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void process() throws Exception {
	HSSFEventFactory hssfEventFactory = new HSSFEventFactory();
	hssfEventFactory.processWorkbookEvents(this.request, this.fileSystem);
}