Bug 12526

Summary: [RFE] Using logical conditions in setCellFormula method
Product: POI Reporter: sridevi <sridevi.malladi>
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: enhancement CC: avik
Priority: P3    
Version: 2.0-dev   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description sridevi 2002-09-11 12:45:35 UTC
Hi,

  I am using jakarta-poi-1.8.0-dev-20020910.jar. I want to set formula for a 
particular cell as IF(C8<>0,C8+D8,C10) i.e if the value of cell C8<>0 then the 
resultant should be c8+d8 else the resultant should be the value of cell C10.

  I am doing this using the following method cell.setCellFormula("IF
(C8<>0,C8+D8,C10)").
But it is giving me error.

  Please let me know whether it is a bug or the formula which I am setting is 
not supported in HSSF.


  I will be very thankful for your sooner reply.

  I am getting the following exception 


[WARNING] Unknown Ptg e (14) at cell (7,5)
java.lang.RuntimeException: Cannot Parse, sorry : ) Expected
	at org.apache.poi.hssf.model.FormulaParser.Abort(FormulaParser.java:147)
	at org.apache.poi.hssf.model.FormulaParser.Expected
(FormulaParser.java:154)
	at org.apache.poi.hssf.model.FormulaParser.Match(FormulaParser.java:206)
	at org.apache.poi.hssf.model.FormulaParser.function
(FormulaParser.java:304)
	at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:271)
	at org.apache.poi.hssf.model.FormulaParser.Factor
(FormulaParser.java:352)
	at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:396)
	at org.apache.poi.hssf.model.FormulaParser.Expression
(FormulaParser.java:447)
	at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:485)
	at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula
(HSSFCell.java:710)
	at com.gepower.geep.escheduler.utils.HSSF.rewrite(HSSF.java:156)
	at com.gepower.geep.escheduler.handler.EScheduleHandler.doExportToXL
(EScheduleHandler.java:348)
	at com.gepower.geep.escheduler.handler.EScheduleHandler.process
(EScheduleHandler.java:226)
	at com.gepower.geep.webcontroller.ServletDispatcher.dispatch
(ServletDispatcher.java:93)
	at 
com.gepower.geep.escheduler.servlet.EScheduleControllerServlet.handleRequest
(EScheduleControllerServlet.java:196)
	at com.gepower.geep.webcontroller.ServletDispatcher.doPost
(ServletDispatcher.java:44)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
	at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
	at allaire.jrun.servlet.JRunRequestDispatcher.forward
(JRunRequestDispatcher.java:88)
	at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
	at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
	at allaire.jrun.http.WebEndpoint.run(WebEndpoint.java:107)
	at allaire.jrun.ThreadPool.run(ThreadPool.java:267)
	at allaire.jrun.WorkerThread.run(WorkerThread.java:74)

Rgds,
SM
Comment 1 Andy Oliver 2002-09-12 02:00:32 UTC
HSSF doesn't support "Optimized If" functions yet.  I'm actually working on this
right now.  Can you attach a few sheets with Optimized Ifs?  I've been
generating them but it would be good to get some other cases.  At least writing
them seems to work at the moment, but reading them isn't.  Avik if you get time
can you look at what I've done?  I'm trying to think of an elegant way to do it,
but boy the way these are done is ugly.
Comment 2 Danny Mui 2003-05-08 00:31:02 UTC
formulaparser patched to support all logical operations.  please verify and
thanks for the bug report.