Cell.GetDependents

Cell.GetDependents method

Get all cells whose formula references to this cell directly.

public Cell[] GetDependents(bool isAll)
ParameterTypeDescription
isAllBooleanIndicates whether check formulas in other worksheets

Remarks

If one reference containing this cell appears in one cell’s formula, that cell will be taken as the dependent of this cell, no matter the reference or this cell is used or not while calculating. For example, although cell A2 in formula “=IF(TRUE,A1,A2)” is not used while calculating, this formula is still be taken as A2’s dependent. To get those formulas whose calculated results depend on this cell, please use GetDependentsInCalculation.When tracing dependents for one cell, all formulas in the workbook or worksheet will be analized and checked. So it is a time consumed process. If user need to trace dependents for lots of cells, using this method will cause poor performance. For performance consideration, user should use GetDependentsInCalculation instead. Or, user may gather precedents map of all cells by GetPrecedents firstly, and then build the dependents map according to the precedents map.

Examples

[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)";
Cell[] dependents = cells["B1"].GetDependents(true);
for (int i = 0; i < dependents.Length; i++)
{
     Console.WriteLine(dependents[i].Name);
}

See Also