开发者

Overloading Methods in ExcelDNA

开发者 https://www.devze.com 2023-02-05 23:22 出处:网络
Is it possible to overload methods using ExcelDNA? For instance, my current code: [ExcelFunction(Category = \"Test\",

Is it possible to overload methods using ExcelDNA?

For instance, my current code:

    [ExcelFunction(Category = "Test",
        IsVolatile=true)]
    public static String TestMethod()
    {
        return "Hello Everyone";
    }

    [ExcelFunction(Category = "Test",
        IsVolatile = true)]
    public static String TestMethod(String Name)
    {
        return "Hello, " + Name;
    }

It seems like it should be this straightforward, but it doesn't appear to work when you call the methods from Excel - in fact, they don't even appear (but开发者_StackOverflow one would appear if you commented out the other).


I don't think ExcelDna supports function overloading. I think the best way to approach your problem is to write one function that takes one object as a parameter. Then check whether the object is System.Reflection.Missing - if so it means nothing was passed.

Chris

0

精彩评论

暂无评论...
验证码 换一张
取 消