Hello Josh,

I have an excel sheet with a formula 5*C2 * ESRAMDEB where ESRAMDEB is a
named cell with value 5.
When i try to evaluate the value of this cell using poi (poi 3.5 beta 4), i
get an exception:

org.apache.poi.ss.formula.FormulaParser$FormulaParseException : Specified
name 'ESRAMDEB ' is not a range as expected.

Can you please let me know if this has been fixed in poi or if I can expect
a fix sometime soon.

Thanks & Regards,
Sapan


Josh Micich wrote:
> 
> Hello Sapan,
> 
> The functionality you seem to be describing has been working since version
> 3.2.  Here is some code tested to work on both 3.2 and latest svn trunk:
> //---------------
> HSSFWorkbook wb = new HSSFWorkbook();
> HSSFName name = wb.createName();
> name.setNameName("SomeName");
> name.setReference("Sheet1!B1");
> HSSFRow row = wb.createSheet("Sheet1").createRow(0);
> row.createCell(1).setCellValue(2.0);
> row.createCell(0).setCellFormula("SomeName*5");
> 
> HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
> CellValue cv = fe.evaluate(row.getCell(0));
> assertEquals(10.0, cv.getNumberValue(), 0.0);
> //---------------
> 
> The evaluator can also evaluate workbooks with defined names that were set
> up in Excel:
> //---------------
> InputStream is = new FileInputStream("nameTest.xls");
> HSSFWorkbook wb = new HSSFWorkbook(is);
> HSSFRow row = wb.getSheetAt(0).getRow(0);
> 
> HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
> CellValue cv = fe.evaluate(row.getCell(0));
> assertEquals(10.0, cv.getNumberValue(), 0.0);
> //---------------
> 
> I have just made a guess at the example code you are referring to.  If
> this
> doesn't properly represent what you are trying to do, please post back
> some
> specific code to clarify. It would also be useful to know which version of
> POI you are using.  The error message you describe doesn't seem to be
> possible from any POI version since 2.5 (when HSSFFormulaEvaluator was
> added).  Unfortunately I still don't know how exactly your bug occurred.
> 
> regards,
> Josh
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Name-cell-does-not-work-in-formula-tp21725152p21742347.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to