Bug 12526 - [RFE] Using logical conditions in setCellFormula method
Summary: [RFE] Using logical conditions in setCellFormula method
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 2.0-dev
Hardware: Other other
: P3 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-09-11 12:45 UTC by sridevi
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description sridevi 2002-09-11 12:45:35 UTC

  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
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
	at org.apache.poi.hssf.model.FormulaParser.Match(FormulaParser.java:206)
	at org.apache.poi.hssf.model.FormulaParser.function
	at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:271)
	at org.apache.poi.hssf.model.FormulaParser.Factor
	at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:396)
	at org.apache.poi.hssf.model.FormulaParser.Expression
	at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:485)
	at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula
	at com.gepower.geep.escheduler.utils.HSSF.rewrite(HSSF.java:156)
	at com.gepower.geep.escheduler.handler.EScheduleHandler.doExportToXL
	at com.gepower.geep.escheduler.handler.EScheduleHandler.process
	at com.gepower.geep.webcontroller.ServletDispatcher.dispatch
	at com.gepower.geep.webcontroller.ServletDispatcher.doPost
	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
	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)

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.