C#代码中的Excel公式求值程序 [英] Excel Formula Evaluator in C# code

查看:119
本文介绍了C#代码中的Excel公式求值程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是我要求的改进版本。

我在DB中存储了更多的Excel公式。所以检索它们我需要通过动态编写该公式的逻辑来计算值。

Ex:

Excel公式:

  IF (A> B, 1  2 
A = 4 B = 5



代码生成:

  IF (A> B)
{
Value = 1
}
否则
{
Value = 2
}









我想使用C#在运行时获得Excel for Excel公式的编码。任何人都可以帮我实现这个目标。



谢谢

Mathi

解决方案

< blockquote>



从Microsoft Visual C#.NET自动化Microsoft Excel



除了
$ b $之外,您还需要自动使用c#的excel使用。


b http://support.microsoft.com/kb/302084



您通常会通过 Cell.Value获取单元格的公式并且您通过编写 Cell.Formula 获得基础公式。


您好以下链接工作...这真的很有帮助...





一个微小的表达评估器 [ ^ ]



我很欣赏吃了你的帮助



谢谢&此致,

Mathi


Hi,

This is the improved version of my requirement.
I am having more Excel formulae stored in DB. So retrieving them I need to calculate the values by writing logic for that formula dynamically.
For Ex:
Excel Formula :

IF(A>B,1,2)
A=4 and B=5


Code to be generated:

IF(A>B)
{
Value = 1
}
Else
{
Value = 2
}



Hi,

I would like to get the coding for Evaluation of Excel formula in run time using C#. Could anyone help me to attain this target.

Thanks
Mathi

解决方案

Hi,

Automate Microsoft Excel from Microsoft Visual C#.NET

You will need to automate excel usage from c#.


in addition to
http://support.microsoft.com/kb/302084

You gennerally get the formula of the cell by Cell.Value and you get the underlying formula by writing Cell.Formula.


Hi All the below link worked... Which was really helpful...


A Tiny Expression Evaluator[^]

I appreciate your help

Thanks & Regards,
Mathi


这篇关于C#代码中的Excel公式求值程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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