From 3b7d6f6f67c8dd3d344fb35c8f1e88850f11398c Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 8 Apr 2011 15:23:18 +0000 Subject: [PATCH] Add unit test showing that bug #51024 is incorrect git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1090293 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/usermodel/TestBugs.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index b3c525ae92..cb1ba7da91 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2075,4 +2075,34 @@ if(1==2) { assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula()); assertEquals(54.0+24.0-60, s.getRow(7).getCell(0).getNumericCellValue()); } + + /** + * HLookup and VLookup with optional arguments + */ + public void test51024() throws Exception { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + HSSFRow r1 = s.createRow(0); + HSSFRow r2 = s.createRow(1); + + r1.createCell(0).setCellValue("v A1"); + r2.createCell(0).setCellValue("v A2"); + r1.createCell(1).setCellValue("v B1"); + + HSSFCell c = r1.createCell(4); + + HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb); + + c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1)"); + assertEquals("v A1", eval.evaluate(c).getStringValue()); + + c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, 1)"); + assertEquals("v A1", eval.evaluate(c).getStringValue()); + + c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1)"); + assertEquals("v A1", eval.evaluate(c).getStringValue()); + + c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, 1)"); + assertEquals("v A1", eval.evaluate(c).getStringValue()); + } } -- 2.39.5