My Problem is that i want to use the WorksheetFunction
method CountIf
in C# for Excel.
And I'm always getting an 2 dim object array from that function
double[,] zn1 = wsf.CountIfs(cSheet.Range[cSheet.Cells[13, 1],
cSheet.Cells[20, 1]], sName + sName);
(It works only with double[,] zn1
or var zn1
, otherwise I'm getting an error that the object array obj[,]
can't be converted to a double
or double[]
, string[]
etc.")
where wsf
is defined as
Excel.Application xl = new Excel.Application();
Excel.WorksheetFunction wsf = xl.WorksheetFunction;
So when I run it, I'm getting a 2 dim object array, which has the same length as the Range, I'm looking for, and all entries contain the same number "-2146826273".
And If I convert the array to a 1 dim double array, the return is System.Double[]
.
object[] to = zn1.Cast<object>().ToArray();
object[] res = to as object[];
double[] sRes;
sRes = res.OfType<double>().ToArray();
All other WorksheetFunction
methods are working well and without errors.
So my question is how, do I get an normal value for the WorksheetFunction
method CountIfs(...)
?
And yes I have to use WorksheetFunction
methods and I can't enter it like a Formula with a string.