From e9ae2d1b6d04b39e3d90a69397b2c8d61bcb2613 Mon Sep 17 00:00:00 2001 From: TimLee88 Date: Thu, 9 Nov 2023 08:52:30 +0800 Subject: [PATCH] Update XSSFRowColShifter.cs --- .../UserModel/Helpers/XSSFRowColShifter.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ooxml/XSSF/UserModel/Helpers/XSSFRowColShifter.cs b/ooxml/XSSF/UserModel/Helpers/XSSFRowColShifter.cs index cc0d62a99..6b77d7eb6 100644 --- a/ooxml/XSSF/UserModel/Helpers/XSSFRowColShifter.cs +++ b/ooxml/XSSF/UserModel/Helpers/XSSFRowColShifter.cs @@ -97,21 +97,26 @@ public static void UpdateRowFormulas(IRow row, FormulaShifter Shifter) int si = (int)f.si; CT_CellFormula sf = sheet.GetSharedFormula(si); sf.Value = ShiftedFormula; + UpdateRefInCTCellFormula(row, Shifter, sf); } } } - if (f.isSetRef()) - { //Range of cells which the formula applies to. - string ref1 = f.@ref; - string ShiftedRef = ShiftFormula(row, ref1, Shifter); - if (ShiftedRef != null) - { - f.@ref = ShiftedRef; - } + //Range of cells which the formula applies to. + UpdateRefInCTCellFormula(row, Shifter, f); } } } + + + private static void UpdateRefInCTCellFormula(IRow row, FormulaShifter Shifter, CT_CellFormula f) + { + if (f.isSetRef()) + { + string ref1 = f.@ref; + string shiftedRef = ShiftFormula(row, ref1, Shifter); + if (shiftedRef != null) f.@ref = shiftedRef; + } } ///