public void TestFormattedNumbersExcel5() { foreach (String ver in new String[] { "5", "95" }) { OldExcelExtractor extractor = CreateExtractor("testEXCEL_" + ver + ".xls"); String text = extractor.Text; // Simple numbers AssertContains(text, "1"); // Numbers which come from formulas AssertContains(text, "13"); AssertContains(text, "169"); // Formatted numbers // TODO // AssertContains(text, "100.00%"); // AssertContains(text, "155.00%"); // AssertContains(text, "1,125"); // AssertContains(text, "189,945"); // AssertContains(text, "1,234,500"); // AssertContains(text, "$169.00"); // AssertContains(text, "$1,253.82"); extractor.Close(); } }
public void TestSimpleExcel5() { foreach (String ver in new String[] { "5", "95" }) { OldExcelExtractor extractor = CreateExtractor("testEXCEL_" + ver + ".xls"); // Check we can call GetText without error String text = extractor.Text; // Check we find a few words we expect in there AssertContains(text, "Sample Excel"); AssertContains(text, "Written and saved"); // Check we find a few numbers we expect in there AssertContains(text, "15"); AssertContains(text, "169"); // Check we got the sheet names (new formats only) AssertContains(text, "Sheet: Feuil3"); // Check the type Assert.AreEqual(5, extractor.BiffVersion); Assert.AreEqual(0x05, extractor.FileType); extractor.Close(); } }
public void TestSimpleExcel3NoReading() { OldExcelExtractor extractor = CreateExtractor("testEXCEL_3.xls"); Assert.IsNotNull(extractor); extractor.Close(); }
public void TestOpenNonExistingFile() { // a file that exists, but is a different format try { OldExcelExtractor extractor = new OldExcelExtractor(new FileInfo("notexistingfile.xls")); extractor.Close(); Assert.Fail("Should catch Exception here"); } catch (FileNotFoundException) { // expected here } }
public void TestDirectoryNode() { FileInfo file = HSSFTestDataSamples.GetSampleFile("FormulaRefs.xls"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { OldExcelExtractor extractor = new OldExcelExtractor(fs.Root); extractor.Close(); } finally { fs.Close(); } }
public void TestInputStreamNPOIHeader() { FileInfo file = HSSFTestDataSamples.GetSampleFile("FormulaRefs.xls"); Stream stream = file.OpenRead(); try { OldExcelExtractor extractor = new OldExcelExtractor(stream); extractor.Close(); } finally { stream.Close(); } }
public void TestFromFile() { foreach (String ver in new String[] { "4", "5", "95" }) { String filename = "testEXCEL_" + ver + ".xls"; FileInfo f = HSSFTestDataSamples.GetSampleFile(filename); OldExcelExtractor extractor = new OldExcelExtractor(f); String text = extractor.Text; Assert.IsNotNull(text); Assert.IsTrue(text.Length > 100); extractor.Close(); } }
public void TestInputStream() { FileInfo file = HSSFTestDataSamples.GetSampleFile("testEXCEL_3.xls"); Stream stream = file.OpenRead(); try { OldExcelExtractor extractor = new OldExcelExtractor(stream); String text = extractor.Text; Assert.IsNotNull(text); extractor.Close(); } finally { stream.Close(); } }
public void TestDirectoryNodeInvalidFile() { FileStream file = POIDataSamples.GetDocumentInstance().GetFile("test.doc"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { OldExcelExtractor extractor = new OldExcelExtractor(fs.Root); extractor.Close(); Assert.Fail("Should catch exception here"); } catch (FileNotFoundException) { // expected here } finally { fs.Close(); } }
public void TestFormattedNumbersExcel4() { OldExcelExtractor extractor = CreateExtractor("testEXCEL_4.xls"); String text = extractor.Text; // Simple numbers AssertContains(text, "151"); AssertContains(text, "784"); // Numbers which come from formulas AssertContains(text, "0.398"); // TODO Rounding AssertContains(text, "624"); // Formatted numbers // TODO // AssertContains(text, "55,624"); // AssertContains(text, "11,743,477"); extractor.Close(); }
public void TestStrings() { OldExcelExtractor extractor = CreateExtractor("testEXCEL_4.xls"); String text = extractor.Text; // Simple strings AssertContains(text, "Table 10 -- Examination Coverage:"); AssertContains(text, "Recommended and Average Recommended Additional Tax After"); AssertContains(text, "Individual income tax returns, total"); // More complicated strings AssertContains(text, "$100,000 or more"); AssertContains(text, "S corporation returns, Form 1120S [10,15]"); AssertContains(text, "individual income tax return \u201Cshort forms.\u201D"); // Formula based strings // TODO Find some then test extractor.Close(); }
public void TestSimpleExcel4() { OldExcelExtractor extractor = CreateExtractor("testEXCEL_4.xls"); // Check we can call GetText without error String text = extractor.Text; // Check we find a few words we expect in there AssertContains(text, "Size"); AssertContains(text, "Returns"); // Check we find a few numbers we expect in there AssertContains(text, "11"); AssertContains(text, "784"); // Check the type Assert.AreEqual(4, extractor.BiffVersion); Assert.AreEqual(0x10, extractor.FileType); extractor.Close(); }
public void TestSimpleExcel3() { OldExcelExtractor extractor = CreateExtractor("testEXCEL_3.xls"); // Check we can call GetText without error String text = extractor.Text; // Check we find a few words we expect in there AssertContains(text, "Season beginning August"); AssertContains(text, "USDA"); // Check we find a few numbers we expect in there AssertContains(text, "347"); AssertContains(text, "228"); // Check we find a few string-literal dates in there AssertContains(text, "1981/82"); // Check the type Assert.AreEqual(3, extractor.BiffVersion); Assert.AreEqual(0x10, extractor.FileType); extractor.Close(); }