HSSFSheet s = workbook.createSheet("Foo");
s.createRow(0).createCell((short)0).setCellValue(1.1);
s.createRow(1).createCell((short)0).setCellValue(2.3);
s.createRow(2).createCell((short)2).setCellValue(3.1);
HSSFName name = workbook.createName();
name.setNameName("testName");
name.setReference("A1:A2");
fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
fp.parse();
ptgs = fp.getRPNPtg();
assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
assertEquals(NamePtg.class, ptgs[0].getClass());
assertEquals(FuncVarPtg.class, ptgs[1].getClass());
// Now make it a single cell
name.setReference("C3");
fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
fp.parse();
ptgs = fp.getRPNPtg();
assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
assertEquals(NamePtg.class, ptgs[0].getClass());
assertEquals(FuncVarPtg.class, ptgs[1].getClass());
// And make it non-contiguous
name.setReference("A1:A2,C3");
fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
fp.parse();
ptgs = fp.getRPNPtg();
assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
assertEquals(NamePtg.class, ptgs[0].getClass());