You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestXSSFFormulaEvaluation.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xssf.usermodel;
  16. import static org.junit.Assert.assertEquals;
  17. import static org.junit.Assert.assertNotNull;
  18. import static org.junit.Assert.assertSame;
  19. import static org.junit.Assert.fail;
  20. import java.io.IOException;
  21. import java.util.HashMap;
  22. import java.util.Map;
  23. import org.apache.poi.hssf.HSSFTestDataSamples;
  24. import org.apache.poi.ss.usermodel.BaseTestFormulaEvaluator;
  25. import org.apache.poi.ss.usermodel.Cell;
  26. import org.apache.poi.ss.usermodel.CellValue;
  27. import org.apache.poi.ss.usermodel.CreationHelper;
  28. import org.apache.poi.ss.usermodel.FormulaEvaluator;
  29. import org.apache.poi.ss.usermodel.Row;
  30. import org.apache.poi.ss.usermodel.Sheet;
  31. import org.apache.poi.ss.usermodel.Workbook;
  32. import org.apache.poi.ss.util.CellReference;
  33. import org.apache.poi.xssf.XSSFITestDataProvider;
  34. import org.apache.poi.xssf.XSSFTestDataSamples;
  35. import org.junit.Ignore;
  36. import org.junit.Test;
  37. public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
  38. public TestXSSFFormulaEvaluation() {
  39. super(XSSFITestDataProvider.instance);
  40. }
  41. @Test
  42. public void testSharedFormulas() throws IOException {
  43. baseTestSharedFormulas("shared_formulas.xlsx");
  44. }
  45. @Test
  46. public void testSharedFormulas_evaluateInCell() throws IOException {
  47. XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("49872.xlsx");
  48. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  49. XSSFSheet sheet = wb.getSheetAt(0);
  50. double result = 3.0;
  51. // B3 is a master shared formula, C3 and D3 don't have the formula written in their f element.
  52. // Instead, the attribute si for a particular cell is used to figure what the formula expression
  53. // should be based on the cell's relative location to the master formula, e.g.
  54. // B3: <f t="shared" ref="B3:D3" si="0">B1+B2</f>
  55. // C3 and D3: <f t="shared" si="0"/>
  56. // get B3 and evaluate it in the cell
  57. XSSFCell b3 = sheet.getRow(2).getCell(1);
  58. assertEquals(result, evaluator.evaluateInCell(b3).getNumericCellValue(), 0);
  59. //at this point the master formula is gone, but we are still able to evaluate dependent cells
  60. XSSFCell c3 = sheet.getRow(2).getCell(2);
  61. assertEquals(result, evaluator.evaluateInCell(c3).getNumericCellValue(), 0);
  62. XSSFCell d3 = sheet.getRow(2).getCell(3);
  63. assertEquals(result, evaluator.evaluateInCell(d3).getNumericCellValue(), 0);
  64. wb.close();
  65. }
  66. /**
  67. * Evaluation of cell references with column indexes greater than 255. See bugzilla 50096
  68. */
  69. @Test
  70. public void testEvaluateColumnGreaterThan255() throws IOException {
  71. XSSFWorkbook wb = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("50096.xlsx");
  72. XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  73. /*
  74. * The first row simply contains the numbers 1 - 300.
  75. * The second row simply refers to the cell value above in the first row by a simple formula.
  76. */
  77. for (int i = 245; i < 265; i++) {
  78. XSSFCell cell_noformula = wb.getSheetAt(0).getRow(0).getCell(i);
  79. XSSFCell cell_formula = wb.getSheetAt(0).getRow(1).getCell(i);
  80. CellReference ref_noformula = new CellReference(cell_noformula.getRowIndex(), cell_noformula.getColumnIndex());
  81. CellReference ref_formula = new CellReference(cell_noformula.getRowIndex(), cell_noformula.getColumnIndex());
  82. String fmla = cell_formula.getCellFormula();
  83. // assure that the formula refers to the cell above.
  84. // the check below is 'deep' and involves conversion of the shared formula:
  85. // in the sample file a shared formula in GN1 is spanned in the range GN2:IY2,
  86. assertEquals(ref_noformula.formatAsString(), fmla);
  87. CellValue cv_noformula = evaluator.evaluate(cell_noformula);
  88. CellValue cv_formula = evaluator.evaluate(cell_formula);
  89. assertEquals("Wrong evaluation result in " + ref_formula.formatAsString(),
  90. cv_noformula.getNumberValue(), cv_formula.getNumberValue(), 0);
  91. }
  92. wb.close();
  93. }
  94. /**
  95. * Related to bugs #56737 and #56752 - XSSF workbooks which have
  96. * formulas that refer to cells and named ranges in multiple other
  97. * workbooks, both HSSF and XSSF ones
  98. */
  99. @Test
  100. public void testReferencesToOtherWorkbooks() throws Exception {
  101. XSSFWorkbook wb = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("ref2-56737.xlsx");
  102. XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  103. XSSFSheet s = wb.getSheetAt(0);
  104. // References to a .xlsx file
  105. Row rXSLX = s.getRow(2);
  106. Cell cXSLX_cell = rXSLX.getCell(4);
  107. Cell cXSLX_sNR = rXSLX.getCell(6);
  108. Cell cXSLX_gNR = rXSLX.getCell(8);
  109. assertEquals("[1]Uses!$A$1", cXSLX_cell.getCellFormula());
  110. assertEquals("[1]Defines!NR_To_A1", cXSLX_sNR.getCellFormula());
  111. assertEquals("[1]!NR_Global_B2", cXSLX_gNR.getCellFormula());
  112. assertEquals("Hello!", cXSLX_cell.getStringCellValue());
  113. assertEquals("Test A1", cXSLX_sNR.getStringCellValue());
  114. assertEquals(142.0, cXSLX_gNR.getNumericCellValue(), 0);
  115. // References to a .xls file
  116. Row rXSL = s.getRow(4);
  117. Cell cXSL_cell = rXSL.getCell(4);
  118. Cell cXSL_sNR = rXSL.getCell(6);
  119. Cell cXSL_gNR = rXSL.getCell(8);
  120. assertEquals("[2]Uses!$C$1", cXSL_cell.getCellFormula());
  121. assertEquals("[2]Defines!NR_To_A1", cXSL_sNR.getCellFormula());
  122. assertEquals("[2]!NR_Global_B2", cXSL_gNR.getCellFormula());
  123. assertEquals("Hello!", cXSL_cell.getStringCellValue());
  124. assertEquals("Test A1", cXSL_sNR.getStringCellValue());
  125. assertEquals(142.0, cXSL_gNR.getNumericCellValue(), 0);
  126. // Try to evaluate without references, won't work
  127. // (At least, not unit we fix bug #56752 that is)
  128. try {
  129. evaluator.evaluate(cXSL_cell);
  130. fail("Without a fix for #56752, shouldn't be able to evaluate a " +
  131. "reference to a non-provided linked workbook");
  132. } catch(Exception e) {
  133. // expected here
  134. }
  135. // Setup the environment
  136. Map<String,FormulaEvaluator> evaluators = new HashMap<>();
  137. evaluators.put("ref2-56737.xlsx", evaluator);
  138. evaluators.put("56737.xlsx",
  139. _testDataProvider.openSampleWorkbook("56737.xlsx").getCreationHelper().createFormulaEvaluator());
  140. evaluators.put("56737.xls",
  141. HSSFTestDataSamples.openSampleWorkbook("56737.xls").getCreationHelper().createFormulaEvaluator());
  142. evaluator.setupReferencedWorkbooks(evaluators);
  143. // Try evaluating all of them, ensure we don't blow up
  144. for(Row r : s) {
  145. for (Cell c : r) {
  146. evaluator.evaluate(c);
  147. }
  148. }
  149. // And evaluate the other way too
  150. evaluator.evaluateAll();
  151. // Static evaluator won't work, as no references passed in
  152. try {
  153. XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
  154. fail("Static method lacks references, shouldn't work");
  155. } catch(Exception e) {
  156. // expected here
  157. }
  158. // Evaluate specific cells and check results
  159. assertEquals("\"Hello!\"", evaluator.evaluate(cXSLX_cell).formatAsString());
  160. assertEquals("\"Test A1\"", evaluator.evaluate(cXSLX_sNR).formatAsString());
  161. assertEquals("142.0", evaluator.evaluate(cXSLX_gNR).formatAsString());
  162. assertEquals("\"Hello!\"", evaluator.evaluate(cXSL_cell).formatAsString());
  163. assertEquals("\"Test A1\"", evaluator.evaluate(cXSL_sNR).formatAsString());
  164. assertEquals("142.0", evaluator.evaluate(cXSL_gNR).formatAsString());
  165. // Add another formula referencing these workbooks
  166. Cell cXSL_cell2 = rXSL.createCell(40);
  167. cXSL_cell2.setCellFormula("[56737.xls]Uses!$C$1");
  168. // TODO Shouldn't it become [2] like the others?
  169. assertEquals("[56737.xls]Uses!$C$1", cXSL_cell2.getCellFormula());
  170. assertEquals("\"Hello!\"", evaluator.evaluate(cXSL_cell2).formatAsString());
  171. // Now add a formula that refers to yet another (different) workbook
  172. // Won't work without the workbook being linked
  173. Cell cXSLX_nw_cell = rXSLX.createCell(42);
  174. try {
  175. cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1");
  176. fail("New workbook not linked, shouldn't be able to add");
  177. } catch (Exception e) {
  178. // expected here
  179. }
  180. // Link and re-try
  181. try (Workbook alt = new XSSFWorkbook()) {
  182. alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
  183. // TODO Implement the rest of this, see bug #57184
  184. /*
  185. wb.linkExternalWorkbook("alt.xlsx", alt);
  186. cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1");
  187. // Check it - TODO Is this correct? Or should it become [3]Sheet1!$A$1 ?
  188. assertEquals("[alt.xlsx]Sheet1!$A$1", cXSLX_nw_cell.getCellFormula());
  189. // Evaluate it, without a link to that workbook
  190. try {
  191. evaluator.evaluate(cXSLX_nw_cell);
  192. fail("No cached value and no link to workbook, shouldn't evaluate");
  193. } catch(Exception e) {}
  194. // Add a link, check it does
  195. evaluators.put("alt.xlsx", alt.getCreationHelper().createFormulaEvaluator());
  196. evaluator.setupReferencedWorkbooks(evaluators);
  197. evaluator.evaluate(cXSLX_nw_cell);
  198. assertEquals("In another workbook", cXSLX_nw_cell.getStringCellValue());
  199. */
  200. }
  201. wb.close();
  202. }
  203. /**
  204. * If a formula references cells or named ranges in another workbook,
  205. * but that isn't available at evaluation time, the cached values
  206. * should be used instead
  207. * TODO Add the support then add a unit test
  208. * See bug #56752
  209. */
  210. @Test
  211. @Ignore
  212. public void testCachedReferencesToOtherWorkbooks() throws Exception {
  213. // TODO
  214. fail("unit test not written yet");
  215. }
  216. /**
  217. * A handful of functions (such as SUM, COUNTA, MIN) support
  218. * multi-sheet references (eg Sheet1:Sheet3!A1 = Cell A1 from
  219. * Sheets 1 through Sheet 3).
  220. * This test, based on common test files for HSSF and XSSF, checks
  221. * that we can correctly evaluate these
  222. */
  223. @Test
  224. public void testMultiSheetReferencesHSSFandXSSF() throws Exception {
  225. Workbook wb1 = HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls");
  226. Workbook wb2 = XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx");
  227. for (Workbook wb : new Workbook[] {wb1,wb2}) {
  228. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  229. Sheet s1 = wb.getSheetAt(0);
  230. // Simple SUM over numbers
  231. Cell sumF = s1.getRow(2).getCell(0);
  232. assertNotNull(sumF);
  233. assertEquals("SUM(Sheet1:Sheet3!A1)", sumF.getCellFormula());
  234. assertEquals("Failed for " + wb.getClass(), "66.0", evaluator.evaluate(sumF).formatAsString());
  235. // Various Stats formulas on numbers
  236. Cell avgF = s1.getRow(2).getCell(1);
  237. assertNotNull(avgF);
  238. assertEquals("AVERAGE(Sheet1:Sheet3!A1)", avgF.getCellFormula());
  239. assertEquals("22.0", evaluator.evaluate(avgF).formatAsString());
  240. Cell minF = s1.getRow(3).getCell(1);
  241. assertNotNull(minF);
  242. assertEquals("MIN(Sheet1:Sheet3!A$1)", minF.getCellFormula());
  243. assertEquals("11.0", evaluator.evaluate(minF).formatAsString());
  244. Cell maxF = s1.getRow(4).getCell(1);
  245. assertNotNull(maxF);
  246. assertEquals("MAX(Sheet1:Sheet3!A$1)", maxF.getCellFormula());
  247. assertEquals("33.0", evaluator.evaluate(maxF).formatAsString());
  248. Cell countF = s1.getRow(5).getCell(1);
  249. assertNotNull(countF);
  250. assertEquals("COUNT(Sheet1:Sheet3!A$1)", countF.getCellFormula());
  251. assertEquals("3.0", evaluator.evaluate(countF).formatAsString());
  252. // Various CountAs on Strings
  253. Cell countA_1F = s1.getRow(2).getCell(2);
  254. assertNotNull(countA_1F);
  255. assertEquals("COUNTA(Sheet1:Sheet3!C1)", countA_1F.getCellFormula());
  256. assertEquals("3.0", evaluator.evaluate(countA_1F).formatAsString());
  257. Cell countA_2F = s1.getRow(2).getCell(3);
  258. assertNotNull(countA_2F);
  259. assertEquals("COUNTA(Sheet1:Sheet3!D1)", countA_2F.getCellFormula());
  260. assertEquals("0.0", evaluator.evaluate(countA_2F).formatAsString());
  261. Cell countA_3F = s1.getRow(2).getCell(4);
  262. assertNotNull(countA_3F);
  263. assertEquals("COUNTA(Sheet1:Sheet3!E1)", countA_3F.getCellFormula());
  264. assertEquals("3.0", evaluator.evaluate(countA_3F).formatAsString());
  265. }
  266. wb2.close();
  267. wb1.close();
  268. }
  269. /**
  270. * A handful of functions (such as SUM, COUNTA, MIN) support
  271. * multi-sheet areas (eg Sheet1:Sheet3!A1:B2 = Cell A1 to Cell B2,
  272. * from Sheets 1 through Sheet 3).
  273. * This test, based on common test files for HSSF and XSSF, checks
  274. * that we can correctly evaluate these
  275. */
  276. @Test
  277. public void testMultiSheetAreasHSSFandXSSF() throws IOException {
  278. Workbook wb1 = HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls");
  279. Workbook wb2 = XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx");
  280. for (Workbook wb : new Workbook[]{wb1,wb2}) {
  281. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  282. Sheet s1 = wb.getSheetAt(0);
  283. // SUM over a range
  284. Cell sumFA = s1.getRow(2).getCell(7);
  285. assertNotNull(sumFA);
  286. assertEquals("SUM(Sheet1:Sheet3!A1:B2)", sumFA.getCellFormula());
  287. assertEquals("Failed for " + wb.getClass(), "110.0", evaluator.evaluate(sumFA).formatAsString());
  288. // Various Stats formulas on ranges of numbers
  289. Cell avgFA = s1.getRow(2).getCell(8);
  290. assertNotNull(avgFA);
  291. assertEquals("AVERAGE(Sheet1:Sheet3!A1:B2)", avgFA.getCellFormula());
  292. assertEquals("27.5", evaluator.evaluate(avgFA).formatAsString());
  293. Cell minFA = s1.getRow(3).getCell(8);
  294. assertNotNull(minFA);
  295. assertEquals("MIN(Sheet1:Sheet3!A$1:B$2)", minFA.getCellFormula());
  296. assertEquals("11.0", evaluator.evaluate(minFA).formatAsString());
  297. Cell maxFA = s1.getRow(4).getCell(8);
  298. assertNotNull(maxFA);
  299. assertEquals("MAX(Sheet1:Sheet3!A$1:B$2)", maxFA.getCellFormula());
  300. assertEquals("44.0", evaluator.evaluate(maxFA).formatAsString());
  301. Cell countFA = s1.getRow(5).getCell(8);
  302. assertNotNull(countFA);
  303. assertEquals("COUNT(Sheet1:Sheet3!$A$1:$B$2)", countFA.getCellFormula());
  304. assertEquals("4.0", evaluator.evaluate(countFA).formatAsString());
  305. }
  306. wb2.close();
  307. wb1.close();
  308. }
  309. // bug 57721
  310. @Test
  311. public void structuredReferences() throws IOException {
  312. verifyAllFormulasInWorkbookCanBeEvaluated("evaluate_formula_with_structured_table_references.xlsx");
  313. }
  314. // bug 57840
  315. @Ignore("Takes over a minute to evaluate all formulas in this large workbook. Run this test when profiling for formula evaluation speed.")
  316. @Test
  317. public void testLotsOfFormulasWithStructuredReferencesToCalculatedTableColumns() throws IOException {
  318. verifyAllFormulasInWorkbookCanBeEvaluated("StructuredRefs-lots-with-lookups.xlsx");
  319. }
  320. // FIXME: use junit4 parameterization
  321. private static void verifyAllFormulasInWorkbookCanBeEvaluated(String sampleWorkbook) throws IOException {
  322. XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook(sampleWorkbook);
  323. XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
  324. wb.close();
  325. }
  326. @Test
  327. public void test59736() {
  328. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("59736.xlsx");
  329. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  330. Cell cell = wb.getSheetAt(0).getRow(0).getCell(0);
  331. assertEquals(1, cell.getNumericCellValue(), 0.001);
  332. cell = wb.getSheetAt(0).getRow(1).getCell(0);
  333. CellValue value = evaluator.evaluate(cell);
  334. assertEquals(1, value.getNumberValue(), 0.001);
  335. cell = wb.getSheetAt(0).getRow(2).getCell(0);
  336. value = evaluator.evaluate(cell);
  337. assertEquals(1, value.getNumberValue(), 0.001);
  338. }
  339. @Test
  340. public void evaluateInCellReturnsSameDataType() throws IOException {
  341. XSSFWorkbook wb = new XSSFWorkbook();
  342. wb.createSheet().createRow(0).createCell(0);
  343. XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  344. XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
  345. XSSFCell same = evaluator.evaluateInCell(cell);
  346. assertSame(cell, same);
  347. wb.close();
  348. }
  349. @Test
  350. public void testBug61468() {
  351. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("simple-monthly-budget.xlsx");
  352. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  353. Cell cell = wb.getSheetAt(0).getRow(8).getCell(4);
  354. assertEquals(3750, cell.getNumericCellValue(), 0.001);
  355. CellValue value = evaluator.evaluate(cell);
  356. assertEquals(3750, value.getNumberValue(), 0.001);
  357. }
  358. @Test
  359. @Ignore // this is from an open bug/discussion over handling localization for number formats
  360. public void testBug61495() {
  361. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("61495-test.xlsm");
  362. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  363. Cell cell = wb.getSheetAt(0).getRow(0).getCell(1);
  364. // assertEquals("D 67.10", cell.getStringCellValue());
  365. CellValue value = evaluator.evaluate(cell);
  366. assertEquals("D 67.10", value.getStringValue());
  367. assertEquals("D 0,068", evaluator.evaluate(wb.getSheetAt(0).getRow(1).getCell(1)));
  368. }
  369. /**
  370. * see bug 62275
  371. * @throws IOException
  372. */
  373. @Test
  374. public void testBug62275() throws IOException {
  375. try (Workbook wb = new XSSFWorkbook()) {
  376. Sheet sheet = wb.createSheet();
  377. Row row = sheet.createRow(0);
  378. Cell cell = row.createCell(0);
  379. cell.setCellFormula("vlookup(A2,B1:B5,2,true)");
  380. CreationHelper createHelper = wb.getCreationHelper();
  381. FormulaEvaluator eval = createHelper.createFormulaEvaluator();
  382. eval.evaluate(cell);
  383. }
  384. }
  385. /**
  386. * see bug 62834, handle when a shared formula range doesn't contain only formula cells
  387. * @throws IOException
  388. */
  389. @Test
  390. public void testBug62834() throws IOException {
  391. try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("62834.xlsx")) {
  392. FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
  393. Cell a2 = wb.getSheetAt(0).getRow(1).getCell(0);
  394. Cell value = evaluator.evaluateInCell(a2);
  395. assertEquals("wrong value A2", "a value", value.getStringCellValue());
  396. // evaluator.clearAllCachedResultValues();
  397. Cell a3 = wb.getSheetAt(0).getRow(2).getCell(0);
  398. value = evaluator.evaluateInCell(a3);
  399. assertEquals("wrong value A3", "a value", value.getStringCellValue());
  400. Cell a5 = wb.getSheetAt(0).getRow(4).getCell(0);
  401. value = evaluator.evaluateInCell(a5);
  402. assertEquals("wrong value A5", "another value", value.getStringCellValue());
  403. }
  404. }
  405. }