Exemplo n.º 1
0
        public void TestWithCrazyContinueRecords()
        {
            // Some files have crazy ordering of their continue records
            // Check that we don't break on them (bug #42844)

            HSSFRequest req = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();
            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem fs = new POIFSFileSystem(OpenSample("ContinueRecordProblem.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();
            factory.ProcessWorkbookEvents(req, fs);

            Record[] recs = mockListen.GetRecords();
            // Check we got the records
            Assert.IsTrue(recs.Length > 100);

            // And none of them are continue ones
            for (int i = 0; i < recs.Length; i++)
            {
                Assert.IsFalse(recs[i] is ContinueRecord);
            }

            // Check that the last few records are as we expect
            // (Makes sure we don't accidently skip the end ones)
            int numRec = recs.Length;
            Assert.AreEqual(typeof(DVALRecord), recs[numRec - 3].GetType());
            Assert.AreEqual(typeof(DVRecord), recs[numRec - 2].GetType());
            Assert.AreEqual(typeof(EOFRecord), recs[numRec - 1].GetType());
        }
Exemplo n.º 2
0
        public void TestWithCrazyContinueRecords()
        {
            // Some files have crazy ordering of their continue records
            // Check that we don't break on them (bug #42844)

            HSSFRequest      req        = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();

            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem  fs      = new POIFSFileSystem(OpenSample("ContinueRecordProblem.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();

            factory.ProcessWorkbookEvents(req, fs);

            Record[] recs = mockListen.GetRecords();
            // Check we got the records
            Assert.IsTrue(recs.Length > 100);

            // And none of them are continue ones
            for (int i = 0; i < recs.Length; i++)
            {
                Assert.IsFalse(recs[i] is ContinueRecord);
            }

            // Check that the last few records are as we expect
            // (Makes sure we don't accidently skip the end ones)
            int numRec = recs.Length;

            Assert.AreEqual(typeof(DVALRecord), recs[numRec - 3].GetType());
            Assert.AreEqual(typeof(DVRecord), recs[numRec - 2].GetType());
            Assert.AreEqual(typeof(EOFRecord), recs[numRec - 1].GetType());
        }
Exemplo n.º 3
0
        public void TestUnknownContinueRecords()
        {
            HSSFRequest      req        = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();

            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem  fs      = new POIFSFileSystem(OpenSample("42844.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();

            factory.ProcessWorkbookEvents(req, fs);

            Assert.IsTrue(true, "no errors while Processing the file");
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            HSSFRequest req = new HSSFRequest();
            mockListen = new MockHSSFListener();
            listener = new EventWorkbookBuilder.SheetRecordCollectingListener(mockListen);
            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();
            try
            {
                Stream is1 = HSSFTestDataSamples.OpenSampleFileStream("3dFormulas.xls");
                POIFSFileSystem fs = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }
        }
        private void ProcessFile(String filename)
        {
            HSSFRequest req = new HSSFRequest();
            mockListen = new MockHSSFListener();
            listener = new FormatTrackingHSSFListener(mockListen);
            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();
            try
            {
                Stream is1 = HSSFTestDataSamples.OpenSampleFileStream(filename);
                POIFSFileSystem fs = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }
        }
        private void ProcessFile(string filename)
        {
            HSSFRequest req = new HSSFRequest();

            mockListen = new MockHSSFListener();
            listener   = new FormatTrackingHSSFListener(mockListen);
            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();

            try
            {
                Stream          is1 = HSSFTestDataSamples.OpenSampleFileStream(filename);
                POIFSFileSystem fs  = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            HSSFRequest req = new HSSFRequest();

            mockListen = new MockHSSFListener();
            listener   = new EventWorkbookBuilder.SheetRecordCollectingListener(mockListen);
            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();

            try
            {
                Stream          is1 = HSSFTestDataSamples.OpenSampleFileStream("3dFormulas.xls");
                POIFSFileSystem fs  = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }
        }
        private void ReadRecords(String sampleFileName)
        {
            HSSFRequest req = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();
            MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(mockListen);
            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();
            try
            {
                Stream is1 = HSSFTestDataSamples.OpenSampleFileStream(sampleFileName);
                POIFSFileSystem fs = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }

            r = mockListen.GetRecords();
            Assert.IsTrue(r.Length > 100);
        }
Exemplo n.º 9
0
        public void TestWithMissingRecords()
        {

            HSSFRequest req = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();
            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem fs = new POIFSFileSystem(OpenSample("SimpleWithSkip.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();
            factory.ProcessWorkbookEvents(req, fs);

            Record[] recs = mockListen.GetRecords();
            // Check we got the records
            Assert.IsTrue(recs.Length > 100);

            // Check that the last few records are as we expect
            // (Makes sure we don't accidently skip the end ones)
            int numRec = recs.Length;
            Assert.AreEqual(typeof(WindowTwoRecord), recs[numRec - 3].GetType());
            Assert.AreEqual(typeof(SelectionRecord), recs[numRec - 2].GetType());
            Assert.AreEqual(typeof(EOFRecord), recs[numRec - 1].GetType());
        }
Exemplo n.º 10
0
        private void ReadRecords(String sampleFileName)
        {
            HSSFRequest      req                    = new HSSFRequest();
            MockHSSFListener mockListen             = new MockHSSFListener();
            MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(mockListen);

            req.AddListenerForAllRecords(listener);

            HSSFEventFactory factory = new HSSFEventFactory();

            try
            {
                Stream          is1 = HSSFTestDataSamples.OpenSampleFileStream(sampleFileName);
                POIFSFileSystem fs  = new POIFSFileSystem(is1);
                factory.ProcessWorkbookEvents(req, fs);
            }
            catch (IOException)
            {
                throw;
            }

            r = mockListen.GetRecords();
            Assert.IsTrue(r.Length > 100);
        }
Exemplo n.º 11
0
        public void TestWithMissingRecords()
        {
            HSSFRequest      req        = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();

            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem  fs      = new POIFSFileSystem(OpenSample("SimpleWithSkip.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();

            factory.ProcessWorkbookEvents(req, fs);

            Record[] recs = mockListen.GetRecords();
            // Check we got the records
            Assert.IsTrue(recs.Length > 100);

            // Check that the last few records are as we expect
            // (Makes sure we don't accidently skip the end ones)
            int numRec = recs.Length;

            Assert.AreEqual(typeof(WindowTwoRecord), recs[numRec - 3].GetType());
            Assert.AreEqual(typeof(SelectionRecord), recs[numRec - 2].GetType());
            Assert.AreEqual(typeof(EOFRecord), recs[numRec - 1].GetType());
        }
Exemplo n.º 12
0
        public void TestUnknownContinueRecords()
        {

            HSSFRequest req = new HSSFRequest();
            MockHSSFListener mockListen = new MockHSSFListener();
            req.AddListenerForAllRecords(mockListen);

            POIFSFileSystem fs = new POIFSFileSystem(OpenSample("42844.xls"));
            HSSFEventFactory factory = new HSSFEventFactory();
            factory.ProcessWorkbookEvents(req, fs);

            Assert.IsTrue(true, "no errors while Processing the file");
        }