tags:

views:

361

answers:

4

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

A: 

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
Formula need to use Excel sintax
Guilherme Ferreira
+2  A: 

You could have a look at

Implementing an Excel-like formula engine

astander
+1  A: 

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
+2  A: 

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

Mike Rosenblum