aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2010-07-26 15:52:57 +0000
committerYegor Kozlov <yegor@apache.org>2010-07-26 15:52:57 +0000
commitaf0406cd100de823fb5de84ae9fa4d54edf46932 (patch)
treed60d6ce4cae42bccb6948415aea0bff46b48835a /src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
parent145e221f877ebbde9e9f291702dcc046b17063d8 (diff)
downloadpoi-af0406cd100de823fb5de84ae9fa4d54edf46932.tar.gz
poi-af0406cd100de823fb5de84ae9fa4d54edf46932.zip
Fixed parsing formulas containing defined names beginning with an underscore, see Bug 9640
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@979329 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
index 3e2feaed02..4e2bb2302a 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
@@ -31,6 +31,9 @@ import org.apache.poi.hssf.record.formula.NamePtg;
import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.util.TempFile;
import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Cell;
/**
* @author Andrew C. Oliver (acoliver at apache dot org)
@@ -935,4 +938,24 @@ public final class TestFormulas extends TestCase {
assertEquals(5.0, evaluator.evaluate(sh2.getRow(0).getCell(1)).getNumberValue(), 0.0);
assertEquals(15.0, evaluator.evaluate(sh2.getRow(0).getCell(2)).getNumberValue(), 0.0);
}
+
+ /**
+ * Verify that FormulaParser handles defined names beginning with underscores,
+ * see Bug #49640
+ */
+ public void testFormulasWithUnderscore(){
+ HSSFWorkbook wb = new HSSFWorkbook();
+ Name nm1 = wb.createName();
+ nm1.setNameName("_score1");
+ nm1.setRefersToFormula("A1");
+
+ Name nm2 = wb.createName();
+ nm2.setNameName("_score2");
+ nm2.setRefersToFormula("A2");
+
+ Sheet sheet = wb.createSheet();
+ Cell cell = sheet.createRow(0).createCell(2);
+ cell.setCellFormula("_score1*SUM(_score1+_score2)");
+ assertEquals("_score1*SUM(_score1+_score2)", cell.getCellFormula());
+ }
}