aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/extractor
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-04-13 14:58:27 +0000
committerNick Burch <nick@apache.org>2008-04-13 14:58:27 +0000
commita54ece7864439a74d084a1ec2478aeccf691dce6 (patch)
treea3b073f006a02fb401039e5a34dbfe1eb2e81603 /src/testcases/org/apache/poi/hssf/extractor
parent51859d65abb6b1d166c394260640fc756b1f4fd3 (diff)
downloadpoi-a54ece7864439a74d084a1ec2478aeccf691dce6.tar.gz
poi-a54ece7864439a74d084a1ec2478aeccf691dce6.zip
Start on a eventusermodel based excel text extractor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@647574 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/extractor')
-rw-r--r--src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
index ad311eb271..b93bc65a24 100644
--- a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
+++ b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
@@ -122,6 +122,52 @@ public final class TestExcelExtractor extends TestCase {
assertEquals("Sheet1\nUPPER(\"xyz\")\nSheet2\nSheet3\n", extractor.getText());
}
+
+ public void testEventExtractor() throws Exception {
+ EventBasedExcelExtractor extractor;
+
+ // First up, a simple file with string
+ // based formulas in it
+ extractor = new EventBasedExcelExtractor(
+ new POIFSFileSystem(
+ HSSFTestDataSamples.openSampleFileStream("SimpleWithFormula.xls")
+ )
+ );
+ extractor.setIncludeSheetNames(true);
+
+ String text = extractor.getText();
+ // TODO
+ assertEquals("Sheet1\nreplaceme\nreplaceme\n(todo - string formulas)\nSheet2\nSheet3\n", text);
+// assertEquals("Sheet1\nreplaceme\nreplaceme\nreplacemereplaceme\nSheet2\nSheet3\n", text);
+
+ extractor.setIncludeSheetNames(false);
+ extractor.setFormulasNotResults(true);
+
+ text = extractor.getText();
+ assertEquals("replaceme\nreplaceme\nCONCATENATE(A1,A2)\n", text);
+
+
+ // Now, a slightly longer file with numeric formulas
+ extractor = new EventBasedExcelExtractor(
+ new POIFSFileSystem(
+ HSSFTestDataSamples.openSampleFileStream("sumifformula.xls")
+ )
+ );
+ extractor.setIncludeSheetNames(false);
+ extractor.setFormulasNotResults(true);
+
+ text = extractor.getText();
+ assertEquals(
+ "1000.0\t1.0\tSUMIF(A1:A5,\">4000\",B1:B5)\n" +
+ "2000.0\t2.0\n" +
+ "3000.0\t3.0\n" +
+ "4000.0\t4.0\n" +
+ "5000.0\t5.0\n",
+ text
+ );
+ }
+
+
/**
* Embded in a non-excel file
*/