public void TestSharedFormulas_EvaluateInCell()
{
XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.OpenSampleWorkbook("49872.xlsx");
IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
ISheet sheet = wb.GetSheetAt(0);
double result = 3.0;
// B3 is a master shared formula, C3 and D3 don't have the formula written in their f element.
// Instead, the attribute si for a particular cell is used to figure what the formula expression
// should be based on the cell's relative location to the master formula, e.g.
// B3: <f t="shared" ref="B3:D3" si="0">B1+B2</f>
// C3 and D3: <f t="shared" si="0"/>
// Get B3 and Evaluate it in the cell
ICell b3 = sheet.GetRow(2).GetCell(1);
Assert.AreEqual(result, Evaluator.EvaluateInCell(b3).NumericCellValue);
//at this point the master formula is gone, but we are still able to Evaluate dependent cells
ICell c3 = sheet.GetRow(2).GetCell(2);
Assert.AreEqual(result, Evaluator.EvaluateInCell(c3).NumericCellValue);
ICell d3 = sheet.GetRow(2).GetCell(3);
Assert.AreEqual(result, Evaluator.EvaluateInCell(d3).NumericCellValue);
}