Problem in calling Excel function

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-04-24T07:34:25Z Indexed on 2010/04/24 7:43 UTC
Read the original article Hit count: 455

Filed under:

I am facing a problem while making Excel's LinEST function.

My program goes like

MyExcel.Application xl = new MyExcel.Application();
MyExcel.WorksheetFunction wsf = xl.WorksheetFunction;
List<int> x = new List<int> { 1, 2, 3, 4 };
List<int> y = new List<int> { 11, 12, 45, 42 };
object o = wsf.LinEst(x, y, true, true);

And the namespace is using MyExcel = Microsoft.Office.Interop.Excel;

The program is compiling smoothly but at runtime it is throwing an error

{System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Actually this is the first time I am using Excel function .. so I am unable to proceed further. If any one has run thru this kind of situation and has solved, please help me.

I am using C# 3.0

Thanks

© Stack Overflow or respective owner

Related posts about c#3.0