我想将一个范围(此时为 1d)传递给我的函数,并返回一个包含范围公式的字符串数组。
到目前为止,这是我的(不工作的)代码:
    public static object[,] ReadFormulas([ExcelArgument(AllowReference=true)]object arg)
    {
        ExcelReference theRef = (ExcelReference)arg;
        object[,] o = (object[,])theRef.GetValue();
        string[,] res = new string[o.GetLength(1),1];
        for(int i=0;i<o.GetLength(1);i++) 
        {
            ExcelReference cellRef = new ExcelReference(theRef.RowFirst+i, theRef.ColumnFirst);
            res[i,0] = XlCall.Excel(XlCall.xlfGetFormula, cellRef) as string;   //Errors here
        }
        return res;
    }