如何使用apache poi 3.6找出excel表格公式运算符? [英] How to find out excel sheet formula operator using apache poi 3.6?

查看:14
本文介绍了如何使用apache poi 3.6找出excel表格公式运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有像 C1+C2 这样的单元格公式.假设我使用 getcellformula() 方法它返回字符串 C1+C2.现在我想按运算符拆分字符串并分别获取每个单元格地址.无论如何要找出 Excel 公式运算符并分别获取每个单元格地址.我怎么办?

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?

请回复我...

沙拉湾.p

推荐答案

这个答案 对您的另一个问题也将回答这个问题.

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

通过 =D4+D6rel="nofollow noreferrer">FormulaParser 给出

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指向单元格引用D4+就是AddPtg

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

注意 POI 使用 Reverse Polish Notation 的格式,即它把 operatorpost-fix 位置.

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

在逆波兰符号中操作符跟随他们的操作数;为了例如,添加三和四,一会写3 4 +"而不是3 +4".

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".

这篇关于如何使用apache poi 3.6找出excel表格公式运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆