Click here to Skip to main content
14,920,659 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :
VB
IF(A>B,1,2)
A=4 and B=5

Code to be generated:
VB
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
Posted
Updated 24-Apr-13 21:54pm
v3
Comments
Maciej Los 4-Apr-13 3:18am
   
Yes, we can help you to attain this target, but...
Please, be more specific and provide more details.
What have you done till now?
Mathi2code 5-Apr-13 2:01am
   
Hi Maciej,

Thanks for the response. I have updated my requirement clearly. Please help me in this. Also have an example like that you can have 'n' Excel formulae like Roundup,IsBlank,recursive IF condition etc.

With Regards,
Mathi

Hi,

Automate Microsoft Excel from Microsoft Visual C#.NET

You will need to automate excel usage from c#.
   
Comments
Kenneth Haugland 4-Apr-13 7:12am
   
5'ed.
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.
   
Comments
Mathi2code 5-Apr-13 1:59am
   
Hi Jose and Kenneth,

Thanks for the response. I think my Question was not clear earlier, now I have updated it in a clear Please help me in this.

With Regards,
Mathi
Kenneth Haugland 25-Apr-13 3:58am
   
With the information you provided here, you might just load a new excel sheet and make it do the calculations. That would be te easiest, using Interop.
Mathi2code 29-Apr-13 1:29am
   
Interop is easiest way but for that we require the excel to installed in our local machine. Also Each and every time when a user uses a session of excel will be opened which is another drawback which I consider. Hence I go for the link which I have added to this post. Please check that.

Regards,
Mathi
Hi All the below link worked... Which was really helpful...


A Tiny Expression Evaluator[^]

I appreciate your help

Thanks & Regards,
Mathi
   
A Tiny Expression Evaluator[^]A Tiny Expression Evaluator[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900