Hi,
What’s wrong with it. I used the following sample code with a simple template file (attached) which has a formula “=(
E100+
E101)/((SUM(
E68:E71)+SUM(
D68:D71))/2)” in A1 cell to get its relevant precedents, it works fine. It should give four areas/ranges which it does as per MS Excel. I am using our latest version of the product i.e. v7.7.0.x (
Please download and try our latest version/fix : Aspose.Cells for .NET v7.7.0.4. ).
e.g
Sample code:
//Instantiating a Workbook object
Workbook workbook = new Workbook(“e:\test2\Book1_Precedents.xlsx”);
Cells cells = workbook.Worksheets[0].Cells;
Aspose.Cells.Cell cell = cells[“A1”];
//Tracing precedents of the cell A1.
//The return array contains ranges and cells.
ReferredAreaCollection ret = cell.GetPrecedents();
//Printing all the precedent cells’ name.
if (ret != null)
{
for (int m = 0; m < ret.Count; m++)
{
ReferredArea area = ret[m];
StringBuilder stringBuilder = new StringBuilder();
if (area.IsExternalLink)
{
stringBuilder.Append(“[”);
stringBuilder.Append(area.ExternalFileName);
stringBuilder.Append(“]”);
}
stringBuilder.Append(area.SheetName);
stringBuilder.Append(“!”);
stringBuilder.Append(CellsHelper.CellIndexToName(area.StartRow, area.StartColumn));
if (area.IsArea)
{
stringBuilder.Append(“:”);
stringBuilder.Append(CellsHelper.CellIndexToName(area.EndRow, area.EndColumn));
}
Console.WriteLine(stringBuilder.ToString());
}
}
Here is the output Console which is fine I think:
Sheet1!E100
Sheet1!E101
Sheet1!E68:E71
Sheet1!D68:D71
If you still have any issue or confusion, give us your template Excel file here, we will check it soon.
Thank you.