Search in sources :

Example 6 with HSSFRequest

use of org.apache.poi.hssf.eventusermodel.HSSFRequest in project poi by apache.

the class XLS2CSVmra method process.

/**
	 * 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);
}
Also used : HSSFEventFactory(org.apache.poi.hssf.eventusermodel.HSSFEventFactory) SheetRecordCollectingListener(org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener) MissingRecordAwareHSSFListener(org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener) HSSFRequest(org.apache.poi.hssf.eventusermodel.HSSFRequest) FormatTrackingHSSFListener(org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener)

Example 7 with HSSFRequest

use of org.apache.poi.hssf.eventusermodel.HSSFRequest in project poi by apache.

the class TestAbortableListener method testAbortStops.

public void testAbortStops() throws Exception {
    AbortableCountingListener l = new AbortableCountingListener(1);
    HSSFRequest req = new HSSFRequest();
    req.addListenerForAllRecords(l);
    HSSFEventFactory f = new HSSFEventFactory();
    assertEquals(0, l.countSeen);
    assertEquals(null, l.lastRecordSeen);
    POIFSFileSystem fs = openSample();
    short res = f.abortableProcessWorkbookEvents(req, fs);
    assertEquals(1234, res);
    assertEquals(1, l.countSeen);
    assertEquals(BOFRecord.sid, l.lastRecordSeen.getSid());
}
Also used : HSSFEventFactory(org.apache.poi.hssf.eventusermodel.HSSFEventFactory) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) HSSFRequest(org.apache.poi.hssf.eventusermodel.HSSFRequest)

Aggregations

HSSFEventFactory (org.apache.poi.hssf.eventusermodel.HSSFEventFactory)7 HSSFRequest (org.apache.poi.hssf.eventusermodel.HSSFRequest)7 InputStream (java.io.InputStream)3 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)3 FormatTrackingHSSFListener (org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener)2 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 SheetRecordCollectingListener (org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener)1 HSSFListener (org.apache.poi.hssf.eventusermodel.HSSFListener)1 MissingRecordAwareHSSFListener (org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener)1 Record (org.apache.poi.hssf.record.Record)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Test (org.junit.Test)1