Excel打开xml sdk – 复制具有范围修改的单元格之间的公式

我有一个单元格(CellFormula)。 我不知道公式内容(可能是总和,ifs或任何其他计算)。
公式可能包括范围。
当您将单元格拖到其他单元格(在Excel应用程序本身手动)公式范围得到更新。
我想要公式编程的副本行为相同的方式。
如果公式包含范围说明符,我想将它们更新到当前行。
有没有一些内置的方式来做到这一点,没有正则expression式操作?

我不知道这是一个很好的解决scheme,涵盖所有的可能性,但…

//Formula update if (cloneFromCell.CellFormula != null && (cloneFromCell.CellFormula.FormulaType == null || !cloneFromCell.CellFormula.FormulaType.HasValue || cloneFromCell.CellFormula.FormulaType.Value == CellFormulaValues.Normal)) { uint cloneRowIndex = OXMLTools.GetRowIndex(cloneFromCell.CellReference); uint offset = rowIndex - cloneRowIndex; exCell.CellFormula.Text = OXMLTools.GetUpdatedFormulaToNewRow(cloneFromCell.CellFormula.Text, offset); } public static string GetUpdatedFormulaToNewRow(string formula, uint offset) { return Regex.Replace(formula, @"[A-Za-z]+\d+", delegate(Match match) { //Calculate the new row for this cell in the formula by the given offset uint oldRow = GetRowIndex(match.Value); string col = GetColumnName(match.Value); uint newRow = oldRow + offset; //Create the new reference for this cell string newRef = col + newRow; return newRef; }); }