February 28th, 2011, 02:46 AM
How to write Excel goal seek function using C#.net
i am using technologies Visual Studio 2010, C#.net, ASP.net and Microsoft office 2003.
I have a requirement to use Excel's Goal seek feature in C#.net. Right now i am using the following code but i am getting the some compilation errors:
private void FindGoal()
Microsoft.Office.Tools.Excel.NamedRange namedRange1 = this.Controls.AddNamedRange(this.Range["A1", missing], "namedRange1");
this.Range["B1", missing].Name = "X";
namedRange1.Formula = "=(X^3)+(3*X^2)+6";
namedRange1.GoalSeek(15, this.Range["B1", missing]);
The following are the errors i am getting right now:
Error 1 'Default2.Object' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'Default2.Object' could be found (are you missing a using directive or an assembly reference?)
Error 2 'Default2.Object' does not contain a definition for 'Range' and no extension method 'Range' accepting a first argument of type 'Default2.Object' could be found (are you missing a using directive or an assembly reference?)
Error 3 The name 'missing' does not exist in the current context
The above code i am getting from the following link please see it for reference:
Please can anyone tell me how to fix these errors.
Thanks in advance.
Tags for this Thread
Click Here to Expand Forum to Full Width