Example #1
0
        public void TestWord6()
        {
            // Too old for the default
            try
            {
                extractor = new WordExtractor(
                        POIDataSamples.GetDocumentInstance().OpenResourceAsStream("Word6.doc")
                );
                Assert.Fail();
            }
            catch (OldWordFileFormatException) { }

            Word6Extractor w6e = new Word6Extractor(
                    POIDataSamples.GetDocumentInstance().OpenResourceAsStream("Word6.doc")
            );
            String text = w6e.Text;

            Assert.IsTrue(text.Contains("The quick brown fox jumps over the lazy dog"));

            String[] tp = w6e.ParagraphText;
            Assert.AreEqual(1, tp.Length);
            Assert.AreEqual("The quick brown fox jumps over the lazy dog\r\n", tp[0]);
        }
Example #2
0
        public void TestWord95()
        {
            // Too old for the default
            try
            {
                extractor = new WordExtractor(
                        POIDataSamples.GetDocumentInstance().OpenResourceAsStream("Word95.doc")
                );
                Assert.Fail();
            }
            catch (OldWordFileFormatException ) { }

            // Can work with the special one
            Word6Extractor w6e = new Word6Extractor(
                    POIDataSamples.GetDocumentInstance().OpenResourceAsStream("Word95.doc")
            );
            String text = w6e.Text;

            Assert.IsTrue(text.Contains("The quick brown fox jumps over the lazy dog"));
            Assert.IsTrue(text.Contains("Paragraph 2"));
            Assert.IsTrue(text.Contains("Paragraph 3. Has some RED text and some BLUE BOLD text in it"));
            Assert.IsTrue(text.Contains("Last (4th) paragraph"));

            String[] tp = w6e.ParagraphText;
            Assert.AreEqual(7, tp.Length);
            Assert.AreEqual("The quick brown fox jumps over the lazy dog\r\n", tp[0]);
            Assert.AreEqual("\r\n", tp[1]);
            Assert.AreEqual("Paragraph 2\r\n", tp[2]);
            Assert.AreEqual("\r\n", tp[3]);
            Assert.AreEqual("Paragraph 3. Has some RED text and some BLUE BOLD text in it.\r\n", tp[4]);
            Assert.AreEqual("\r\n", tp[5]);
            Assert.AreEqual("Last (4th) paragraph.\r\n", tp[6]);
        }