Excel 无法识别来自 closedXML / c# 的公式

Excel don't recognize formulas from closedXML / c#

Info: The following code is in a foreach loop

作品:

indexSheet.Cell("G" + cellIndex).FormulaA1 = "=SUM(A1:A10)";

只有当我直接在 excel 中输入时才有效:

indexSheet.Cell("G" + cellIndex).FormulaA1 = "=FIND(\"erw\";H5)"; // with Property
indexSheet.Cell("G" + cellIndex).SetFormulaA1("=FIND(\"erw\";H5)");  //with Function
indexSheet.Cell("G" + cellIndex).FormulaA1 = $"COUNTIF(H{cellIndex};\"*\"&$C&\"*\")*(MAX($G:G{cellIndex - 1})+1)";
indexSheet.Cell("B" + cellIndex).FormulaA1 = $"=IF(ROW()-{cellIndex}>MAX(G:G);\"\";HYPERLINK(CONCATENATE(\"#\";(INDEX(H:H;MATCH(ROW()-4;G:G;0)));\"!B{cellIndex}\");(INDEX(H:H;MATCH(ROW()-4;G:G;0)))))";

我checked/tried:

  1. 因为在 Whosebug 中存在类似的情况:如果我的函数的语言与我的 excel 语言匹配(均为英语)
  2. 我尝试过更简单的公式是否可以像 SUM()FIND() 这样工作 -->(-SUM 有效,FIND 无效)
  3. 我直接在 excelsheet 中输入了公式(公式在这里工作)
  4. 我在循环外用硬编码的单元格信息尝试了它,没有 "cellindex"-变量
  5. 查看已关闭的XML-文档
  6. 公式开头有等号和没有等号
  7. 我试过关闭XML Vers。 0.76.0 和 0.80.1(最新稳定版)

Excel 给我看这个: Picture1

还有这个: Picture2

图片 2 中的链接 XML-logfile 包含有关已删除部分的信息

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    <logFileName>error035720_03.xml</logFileName><summary>Errors were detected in file 'C:\Users\XXX\Documents\Output\CodeBook.xlsx'</summary>
    <removedRecords>
        <removedRecord>Removed Records: Formula from /xl/worksheets/sheet.xml part</removedRecord>
        <removedRecord>Removed Records: Formula from /xl/calcChain.xml part (Calculation properties)</removedRecord>
    </removedRecords>
</recoveryLog>

您不能使用分号 (;) 来分隔 closedxml 中的参数。像这样使用逗号(,):

indexSheet.Cell("G" + cellIndex).FormulaA1 = "=FIND(\"erw\",H5)";

这就是 SUM(range) 有效但 FIND(find_text;within_text) 无效的原因...