Calling excel function using C#

B

Bhavin Parekh

Hi
I'm using C# (Framework 2.0) and trying to calling excel function using
below dummy code.
It works fine as long as array size of object type array is under 65500 but
as soon as i increase, it throws an error.

Code:
object[] obj = new object[65500];
long indx = 0;
while (indx<65600)
{
obj[indx] = indx;
indx++;

}
Microsoft.Office.Interop.Excel.Application xl = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.WorksheetFunction wsf = xl.WorksheetFunction;
double result = wsf.Percentile(obj, 0.75);


When i increase the size e.g. 65600, it throws below error,
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Please anyone can help on this? Is there any workaround to resolve this
issue?
Thanks
 
F

Fabz

You should not call this method, see the documentation of
IWorksheetFunction.percentile:

"This method supports the .NET Framework infrastructure and is not intended
to be used directly from your code. "

Furthermore, the error much looks like the function simply is not able to
handle more than the maximum number of an array length of an "ushort data
type" which is 65535.

Greetz
Fabz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top