Question

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 one would appear if you commented out the other).

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top