From: Nick Burch Date: Fri, 8 Apr 2011 15:23:18 +0000 (+0000) Subject: Add unit test showing that bug #51024 is incorrect X-Git-Tag: REL_3_8_BETA3~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3b7d6f6f67c8dd3d344fb35c8f1e88850f11398c;p=poi.git 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 --- 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()); + } }