11

I have an Application that need to evaluate Excel Logical Formulas and I use Excel DLL to do this, but DLL isn't it very efficient.

.NET Framework (C#) has any Class that can make this Job?

An sample

I Provide this

=IF(AND(10>=-5;10<0);(-3,8*10+335);IF(AND(10>=0;10<5);(1,4*10+335);IF(AND(10>=5;10<14,4);(-1,2766*10+348,38);IF(AND(10>=14,4;10<25);(-1,5094*10+351,74);IF(AND(10>=25;10<=45);(-1,4*10+349);0)))))

And get this

335,614

Thanks

David Basarab
  • 72,212
  • 42
  • 129
  • 156
Gui Ferreira
  • 4,367
  • 6
  • 28
  • 41
  • This is best and awesome method CLICK [Here](http://stackoverflow.com/questions/1437964/best-and-shortest-way-to-evaluate-mathematical-expressions/1438829#1438829) – Sarbanjeet Mar 26 '14 at 12:12

6 Answers6

11

Yes, agreed, the Excel.Application.Evaluate method can be slow. It usually suits my needs, but it's not lightening fast.

I think the best source for evaluating Excel formulas without the Excel object mode is:

Some other related articles:

Hope this helps...

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Mike Rosenblum
  • 12,027
  • 6
  • 48
  • 64
5

You could have a look at

Implementing an Excel-like formula engine

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
2

I am using ActiveXls and it's doing a great job. It's not a free component so you have to pay for it. I don't know if there are any good and free components out there, but I prefer to have support in case I need it :)

1

We use SpreadsheetGear to do this - but it does a whole lot more than just evaluating formulas, so might be overkill for you.

It does seem to be fast, and provides a quite easy to use .NET API, too.

Ant
  • 5,150
  • 2
  • 33
  • 41
1

I used bcParser.NET is a mathematical expression parser library for the .NET platform. this utility from bestcode organisation and easy to use to calculate all type of formula. refer to this http://www.bestcode.com/html/math_parser_for_dot_net.html

Manoj Gupta
  • 456
  • 4
  • 9
0

There are a couple of math expression parsers out there, e.g. lundin, but I'm not sure they'll parse an excel expression for you. Does it have to be excel?

Paddy
  • 33,309
  • 15
  • 79
  • 114