尝试从UDF写入数组的Excel DNA仅写入单个值

时间:2018-11-13 17:09:03

标签: excel-dna

我正在尝试通过用Excel DNA(v.0.34)编写的UDF将数组函数或动态数组写入Excel。我的结果始终是单个值而不是数组。我在做什么错了?

    [ExcelFunction(Name = "WriteTestArray")]
    public static object[,] WriteTestArray()
    {

        try
        {
            return new object[2, 2] { { "one", "two" }, { "three", "four" } };
        }
        catch
        {
            return new object[,] { { ExcelError.ExcelErrorValue } };
        }
    }

1 个答案:

答案 0 :(得分:1)

要使数组函数与Excel一起使用(在将来的版本中出现“动态数组”支持之前),您需要选择目标范围,然后键入公式并按Ctrl + Shift + Enter提交作为数组公式。显示时将用大括号括起来-例如{=MyFunc(...)}