XLL array of parameters

Add-in Express™ Support Service
That's what is more important than anything else

XLL array of parameters
 
Sebastian Hinz




Posts: 21
Joined: 2008-07-23
Hi,
I am looking for a way to declare a UDF with a number of parameters which I don't know at design time (e.g. like SUM).
I have tried this and it works.
      public static string GetHello(object arg0, [Optional]object arg1)
            {

                StringBuilder sb = new StringBuilder("hello ");
                if( !(arg1 is System.Reflection.Missing))
                {
                    sb.Append(arg1);
                }
                return sb.ToString();
            }


Now I thought it was possible to do something like

public static string GetHello(object arg0, [Optional]object[] args)


but I cannot get this approach to work.
Could you tell me what I am missing here?
Best regards
Sebastian
Posted 20 Jul, 2011 10:14:55 Top
Eugene Astafiev


Guest


Hi Sebastian,

It looks like you need to set the AcceptAsArray property of the ADXExcelParameterDescriptor class to true (see the ADXExcelFunctionCategory component). Anyway, I have found a similar forum http://www.add-in-express.com/forum/read.php?FID=5&TID=9215&MID=47210#message47210 for you. Is it what you are looking for?
Posted 20 Jul, 2011 11:08:25 Top
Sebastian Hinz




Posts: 21
Joined: 2008-07-23
Hi Eugene,

I think this is not what I am looking for, or maybe I don't understand it right.
I have achieved to process an Array in my method but only for a range of cells (e.g. in Excel: =GetHello(A1:A12)
What I want to achieve is something like
=GetHello(A1;B2;A3;A4) without knowing upfront how many parameters will be entered.

Best regards
Sebastian
Posted 20 Jul, 2011 11:15:05 Top
Eugene Astafiev


Guest


Hi Sebastian,

Thank you for the detailed description. Now I can imagine the whole picture ;-)

I regret to tell you but there is no way to implement such scenario in a managed programming language. Please use optional parameters instead.
Posted 21 Jul, 2011 09:35:00 Top
Sebastian Hinz




Posts: 21
Joined: 2008-07-23
Hi Eugene,

thank you for your answer.
Okay I will go the optional parameters way.
Best regards,
Sebastian
Posted 21 Jul, 2011 09:58:48 Top
Eugene Astafiev


Guest


You are welcome, Sebastian!
Posted 21 Jul, 2011 10:01:17 Top