从Excel公式解析和提取单元格引用? [英] Parsing and extracting cell references from Excel formulas?

查看:59
本文介绍了从Excel公式解析和提取单元格引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找从Excel公式中解析和提取单元格引用的方法.假设我在单元格 P5 中有以下公式:

I am looking to parse and extract cell references from Excel formulas. Let's say I have the following formula inside cell P5:

=SUM(P1:P4)+Q3

我正在寻找公式所涉及的单元格位置的输出以产生答案,即 P1 P2 P3 P4 Q3 作为输出(它们的位置/表示形式也可以接受).

I am looking for an output of the location of the cells involved for the formula to produce an answer, i.e. P1, P2, P3, P4, Q3 as output (their location/representation in some other form is acceptable too).

我的问题是是否有可用的解析器来完成此任务,否则,我应该采用哪种技术.也许我作为示例列出的公式很简单,理想情况下,我希望涵盖所有可能的公式,甚至包括那些在其他工作表和工作簿中都有引用的公式.我期望并且确实希望有一个基于VSTO C#的解决方案,但是我很难在VSTO库中找到一个或什至相关的功能.

My question is whether there is such kind of parser available to accomplish this and if not, what technique I should adopt. Perhaps the formula I have listed as example is quite simple, I would ideally like to cover all potential formulas, maybe even those that have a reference across other sheets and workbooks. I expected and was really hoping for a VSTO C# based solution but I'm having a really difficult time finding one or even relevant functionality in the VSTO library.

推荐答案

从公式中查找先例的完整解决方案具有挑战性:即使Excel的先例工具也不能很好地做到这一点.对于使用C#的起点,请尝试 https://github.com/spreadsheetlab/XLParser

A complete solution to finding precedents from a formula is challenging: even Excel's precedents tool does not do a good job of this. For a starting point using c# try https://github.com/spreadsheetlab/XLParser

这篇关于从Excel公式解析和提取单元格引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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