/// <summary>
        /// Processes a DocumentInputStream into essentially Record events.
        /// </summary>
        /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
        /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
        /// <returns>numeric user-specified result code.</returns>
        protected short GenericProcessEvents(HSSFRequest req, RecordInputStream in1)
        {
            bool   going    = true;
            short  userCode = 0;
            Record r        = null;

            // Create a new RecordStream and use that
            HSSFRecordStream recordStream = new HSSFRecordStream(in1);

            // Process each record as they come in
            while (going)
            {
                r = recordStream.NextRecord();
                if (r != null)
                {
                    userCode = req.ProcessRecord(r);
                    if (userCode != 0)
                    {
                        break;
                    }
                }
                else
                {
                    going = false;
                }
            }

            // All done, return our last code
            return(userCode);
        }
 /// <summary>
 /// Processes a DocumentInputStream into essentially Record events.
 /// If an
 /// <c>AbortableHSSFListener</c>
 ///  causes a halt to Processing during this call
 /// the method will return just as with
 /// <c>abortableProcessEvents</c>
 /// , but no
 /// user code or
 /// <c>HSSFUserException</c>
 ///  will be passed back.
 /// </summary>
 /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
 /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
 public void ProcessEvents(HSSFRequest req, Stream in1)
 {
     try
     {
         GenericProcessEvents(req, new RecordInputStream(in1));
     }
     catch (HSSFUserException)
     { /*If an HSSFUserException user exception Is thrown, ignore it.*/ }
 }
 /// <summary>
 /// Processes a DocumentInputStream into essentially Record events.
 /// If an 
 /// <c>AbortableHSSFListener</c>
 ///  causes a halt to Processing during this call
 /// the method will return just as with 
 /// <c>abortableProcessEvents</c>
 /// , but no
 /// user code or 
 /// <c>HSSFUserException</c>
 ///  will be passed back.
 /// </summary>
 /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
 /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
 public void ProcessEvents(HSSFRequest req, Stream in1)
 {
     try
     {
         GenericProcessEvents(req, new RecordInputStream(in1));
     }
     catch (HSSFUserException)
     {/*If an HSSFUserException user exception Is thrown, ignore it.*/ }
 }
 /// <summary>
 /// Processes a DocumentInputStream into essentially Record events.
 /// </summary>
 /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
 /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
 /// <returns>numeric user-specified result code.</returns>
 public short AbortableProcessEvents(HSSFRequest req, Stream in1)
 {
     return(GenericProcessEvents(req, new RecordInputStream(in1)));
 }
        /// <summary>
        /// Processes a file into essentially record events.
        /// </summary>
        /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
        /// <param name="fs">a POIFS filesystem containing your workbook</param>
        /// <returns>numeric user-specified result code.</returns>
        public short AbortableProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
        {
            Stream in1 = fs.CreateDocumentInputStream("Workbook");

            return(AbortableProcessEvents(req, in1));
        }
        /// <summary>
        /// Processes a file into essentially record events.
        /// </summary>
        /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
        /// <param name="fs">a POIFS filesystem containing your workbook</param>
        public void ProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
        {
            Stream in1 = fs.CreateDocumentInputStream("Workbook");

            ProcessEvents(req, in1);
        }
        /// <summary>
        /// Triggers the extraction.
        /// </summary>
        /// <returns></returns>
        private TextListener TriggerExtraction()
        {
            TextListener tl = new TextListener(includeSheetNames,formulasNotResults);
            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, fs);

            return tl;
        }
 /// <summary>
 /// Processes a file into essentially record events.
 /// </summary>
 /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
 /// <param name="fs">a POIFS filesystem containing your workbook</param>
 /// <returns>numeric user-specified result code.</returns>
 public short AbortableProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
 {
     Stream in1 = fs.CreateDocumentInputStream("Workbook");
     return AbortableProcessEvents(req, in1);
 }
        /// <summary>
        /// Processes a file into essentially record events.
        /// </summary>
        /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
        /// <param name="fs">a POIFS filesystem containing your workbook</param>
        public void ProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
        {
            Stream in1 = fs.CreateDocumentInputStream("Workbook");

            ProcessEvents(req, in1);
        }
Esempio n. 10
0
        /// <summary>
        /// Processes a DocumentInputStream into essentially Record events.
        /// </summary>
        /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
        /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
        /// <returns>numeric user-specified result code.</returns>
        protected short GenericProcessEvents(HSSFRequest req, RecordInputStream in1)
        {
            bool going = true;
            short userCode = 0;
            Record r = null;

            // Create a new RecordStream and use that
            HSSFRecordStream recordStream = new HSSFRecordStream(in1);

            // Process each record as they come in
            while (going)
            {
                r = recordStream.NextRecord();
                if (r != null)
                {
                    userCode = req.ProcessRecord(r);
                    if (userCode != 0) break;
                }
                else
                {
                    going = false;
                }
            }

            // All done, return our last code
            return userCode;
        }
Esempio n. 11
0
 /// <summary>
 /// Processes a DocumentInputStream into essentially Record events.
 /// </summary>
 /// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
 /// <param name="in1">a DocumentInputStream obtained from POIFS's POIFSFileSystem object</param>
 /// <returns>numeric user-specified result code.</returns>
 public short AbortableProcessEvents(HSSFRequest req, Stream in1)
 {
     return GenericProcessEvents(req, new RecordInputStream(in1));
 }