public void TestGetSimpleText() { // a very simple file XSSFExcelExtractor extractor = GetExtractor("sample.xlsx"); String text = extractor.Text; Assert.IsTrue(text.Length > 0); // Check sheet names Assert.IsTrue(text.StartsWith("Sheet1")); Assert.IsTrue(text.EndsWith("Sheet3\n")); // Now without, will have text extractor.SetIncludeSheetNames(false); text = extractor.Text; String CHUNK1 = "Lorem\t111\n" + "ipsum\t222\n" + "dolor\t333\n" + "sit\t444\n" + "amet\t555\n" + "consectetuer\t666\n" + "adipiscing\t777\n" + "elit\t888\n" + "Nunc\t999\n"; String CHUNK2 = "The quick brown fox jumps over the lazy dog\n" + "hello, xssf hello, xssf\n"+ "hello, xssf hello, xssf\n"+ "hello, xssf hello, xssf\n"+ "hello, xssf hello, xssf\n"; Assert.AreEqual( CHUNK1 + "at\t4995\n" + CHUNK2 , text); // Now Get formulas not their values extractor.SetFormulasNotResults(true); text = extractor.Text; Assert.AreEqual( CHUNK1 + "at\tSUM(B1:B9)\n" + CHUNK2, text); // With sheet names too extractor.SetIncludeSheetNames(true); text = extractor.Text; Assert.AreEqual( "Sheet1\n" + CHUNK1 + "at\tSUM(B1:B9)\n" + "rich test\n" + CHUNK2 + "Sheet3\n" , text); extractor.Close(); }
public void TestInlineStrings() { XSSFExcelExtractor extractor = GetExtractor("InlineStrings.xlsx"); extractor.SetFormulasNotResults(true); String text = extractor.Text; // Numbers Assert.IsTrue(text.Contains("43"), "Unable to find expected word in text\n" + text); Assert.IsTrue(text.Contains("22"), "Unable to find expected word in text\n" + text); // Strings Assert.IsTrue(text.Contains("ABCDE"), "Unable to find expected word in text\n" + text); Assert.IsTrue(text.Contains("Long Text"), "Unable to find expected word in text\n" + text); // Inline Strings Assert.IsTrue(text.Contains("1st Inline String"), "Unable to find expected word in text\n" + text); Assert.IsTrue(text.Contains("And More"), "Unable to find expected word in text\n" + text); // Formulas Assert.IsTrue(text.Contains("A2"), "Unable to find expected word in text\n" + text); Assert.IsTrue(text.Contains("A5-A$2"), "Unable to find expected word in text\n" + text); extractor.Close(); }