ExcelDna Argument(Name= getname?)

Jul 25, 2012 at 3:18 PM
Edited Jul 25, 2012 at 3:19 PM

hey guys,

 

I was wondering if it is possible, "rename" the atribute (Name) of a UDF in the runtime.

Someting like,

 

 

[ExcelDna.Integration.ExcelFunction(Description= "XPTO")]             

public static string teste([ExcelDna.Integration.ExcelArgument(Name= getdesc())])            {       //code                        return "";            }
           

public static string getdesc()           {               return "hello";            }

 

it is possible thing to do?

Coordinator
Jul 25, 2012 at 3:30 PM
Edited Jul 25, 2012 at 3:31 PM

Well, you can say 

    [ExcelFunction(Name="SPECIAL.NAME", 
                   Description="My test function")]
    public static object TestFunction(
        [ExcelArgument(
            Name="FIRST.ARG",
            Description="is the first argument")] object input)
    {
        return input;
    }

But C# does not allow you set the attributes at runtime, so you can't call a function to fill them in.

-Govert

Jul 25, 2012 at 3:48 PM
Edited Jul 25, 2012 at 3:49 PM

Hi Govert, thanks for the quick response.

 

The way you sugest ,I have used in UDF's,  but in this specific UDF's, the "Name"/"Description"of the UDF's, will be diferent depending of some facts.

 

I thought there would be some way to change that in runtime.

 

Just one more question, if i had a global array in the Class with the "names", its possible this?

 

array[0] = "nametoudf";


 

 [ExcelFunction(Name="SPECIAL.NAME", 
                   Description="My test function")]
    public static object TestFunction(
        [ExcelArgument(
            Name= array[0],
            Description="is the first argument")] object input)
    {
        return input;
    }

or using the "ExcelDna.Integration.ExcelArgumentAttribute" ?