-
February 28th, 2011, 02:46 AM
#1
How to write Excel goal seek function using C#.net
Hi,
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:
Default.aspx.cs code:
using Microsoft.Office.Tools.Excel;
using Microsoft.Office.Interop.Excel;
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:
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
Please can anyone tell me how to fix these errors.
Thanks in advance.
Regards,
Viswanath.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|