How to find out excel sheet formula operator using apache poi 3.6?

荒凉一梦 提交于 2019-12-11 13:57:27

问题


I have cell formula like C1+C2.suppose i use getcellformula()method it returns the String C1+C2. Now i want to split the String by operator and get the each cell Address separately.Is there anyway to find out the Excel formula operator and get the each cell address separately. How i do?

Please reply me...

Saravanan.p


回答1:


This answer to your other question will answer this as well.

A formula =D4+D6 when parsed via FormulaParser gives

org.apache.poi.hssf.record.formula.RefPtg [D4]
org.apache.poi.hssf.record.formula.RefPtg [D6]
class org.apache.poi.hssf.record.formula.AddPtg

RefPtg points to the cell reference D4, and + is AddPtg

Note POI uses the format of Reverse Polish Notation i.e. it puts which puts the operator in the post-fix position.

In Reverse Polish notation the operators follow their operands; for instance, to add three and four, one would write "3 4 +" rather than "3 + 4".



来源:https://stackoverflow.com/questions/4265118/how-to-find-out-excel-sheet-formula-operator-using-apache-poi-3-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!