Range originalFormulaRange = formulaRange.copy();
for (Range templateRange : rangeDependencies.keySet()) {
if (templateRange.contains(formulaRange)) {
List<Range> resultRanges = rangeDependencies.get(templateRange);
CellReference cellReference = new CellReference(result.getSheetName(worksheet), cellWithFormula.getR());
for (Range resultRange : resultRanges) {
if (resultRange.contains(cellReference)) {
Offset offset = calculateOffset(templateRange, resultRange);
formulaRange = formulaRange.shift(offset.downOffset, offset.rightOffset);
updateFormula(cellWithFormula, originalFormulaRange, formulaRange, calculationChain, formulaCount++);
break;
}
}
}
}
}
for (Cell cellWithFormula : outerFormulas) {
Row row = (Row) cellWithFormula.getParent();
Worksheet worksheet = getWorksheet(row);
Range formulaRange = Range.fromCellFormula(result.getSheetName(worksheet), cellWithFormula);
Range originalFormulaRange = formulaRange.copy();
CellReference formulaCellReference = new CellReference(result.getSheetName(worksheet), cellWithFormula.getR());
BandData parentBand = null;
for (Range resultRange : rangeDependencies.values()) {
if (resultRange.contains(formulaCellReference)) {
BandData formulaCellBand = bandsToResultRanges.inverse().get(resultRange);