I'm building a VSTO Excel add-in, I would like to use Evaluate
to evaluate Excel formulas.
With the following code, when there are some values in A1:A20
, it returns a correct result. For instance, if A1 has 3
as value, in the output, it shows System.Object[,]
, then we can further cast it.
Excel.Application app = Globals.ThisAddIn.Application;
object result = app.Evaluate("=UNIQUE(A1:A20)");
Debug.WriteLine(result);
However, when A1:A20
are empty, in the output, it shows System.Object[*]
.
Does anyone know what System.Object[*]
is? How could I cast such values to get the correct result (e.g., 0
for =UNIQUE(A1:A20)
when A1:A20
are empty)?