1
我想傳遞一個範圍(此時爲1d)到我的函數中,並返回一個包含範圍公式的字符串數組。如何使用ExcelDNA從一個範圍獲取Excel公式?
這裏是我的(不工作)到目前爲止的代碼:
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;
}