GetDependentsInCalculation

Cell.GetDependentsInCalculation method

获取计算结果依赖于该单元格的所有单元格。

public IEnumerator GetDependentsInCalculation(bool recursive)
范围类型描述
recursiveBoolean是否返回那些不直接引用此单元格但引用此单元格其他叶子的依赖项

返回值

枚举器枚举所有依赖项(Cell 对象)

评论

要使用此方法,请确保已将工作簿设置为 的真值EnableCalculationChain并且已经用这个设置完全计算过。 如果没有公式引用这个单元格,会返回null

例子

[C#]

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["A1"].Formula = "=B1+SUM(B1:B10)+[Book1.xls]Sheet1!B2";
cells["A2"].Formula = "=IF(TRUE,B2,B1)";
workbook.Settings.FormulaSettings.EnableCalculationChain = true;
workbook.CalculateFormula();
IEnumerator en = cells["B1"].GetDependentsInCalculation(false);
Console.WriteLine("B1's calculation dependents:");
while(en.MoveNext())
{
    Cell c = (Cell)en.Current;
    Console.WriteLine(c.Name);
}
en = cells["B2"].GetDependentsInCalculation(false);
Console.WriteLine("B2's calculation dependents:");
while(en.MoveNext())
{
    Cell c = (Cell)en.Current;
    Console.WriteLine(c.Name);
}

也可以看看