【发布时间】:2017-10-05 12:54:18
【问题描述】:
我最近从 interop/closedxml 切换到 EPPlus,我注意到 EPPlus 处理 R1C1 绝对引用的方式不同。
考虑下面的代码
int colIndex = 5;
string formula = string.Format("MATCH(@""12345"",C{0},0)", colIndex);
int targetCellRow = 1;
int targetCellColumnAbs = 1;
workSheet.Cells[targetCellRow, targetCellColumnAbs].FormulaR1C1 = formula;
使用 EPPlus 这将导致:
=MATCH("12345";Inkoopdelen!R[4]C[2];0)
使用 InterOp 和 ClosedXML
=MATCH("12345";Inkoopdelen!C5;0)
在我的最终结果中,EPPlus 公式不起作用,因为它引用了一个单元格而不是列范围。它还引用了错误的列。
单元格 A1 中的引用 R[4]C[2] = A 列右侧的两列 = C 列。
对第 5 列的绝对引用应导致 E 列(C[4] 或 C5)。
如何使用 EPPlus 来尊重我在公式中输入的绝对范围引用?
【问题讨论】: