Overloading Methods in ExcelDNA
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
精彩评论