Excel function with arbitrary params

Dec 20, 2011 at 7:40 PM

Hi Govert,

I'd like to create a function that takes arbitrary amount of params of any kind, Is this possible?

Like Foo(A1,B1:B3,C1:E:1)

I tried

[ExcelFunction(Description = "", Category = "SeoTools")]
public static string Foo([ExcelArgument(Description = "")]params object[] vector)
    return "foo";

But it seems not to work.

Best regards

Dec 21, 2011 at 4:22 PM

Hi Niels,

Excel-DNA does not currently have automatic processing of params arrays.

However, you can implement in your function exactly the behaviour Excel-DNA might in future do automatically: You create the function with 255 (or however many) parameters of type object, and then check each of the for type ExcelMissing to see if a value was passed in or not.

The Excel C API does not allow functions to behave in the function wizard exactly as they do in VBA, but Excel-DNA already allows you to fully implement any signature that the C API supports (apart from async functions in Excel 2010). For now you just have to do the extra parameter check and remapping in your own wrapper function.


Dec 22, 2011 at 7:48 AM

Thanks for your answer Govert!

Do you have any roadmap/development plan for Excel-DNA?


Dec 22, 2011 at 8:39 AM

I have a long todo list :-)

Better asynchronous support is likely to be the next big theme, when I get some time to focus on further development.