vol*_*lta 3 c# excel formulas excel-formula closedxml
信息:以下代码在 foreach 循环中
作品:
indexSheet.Cell("G" + cellIndex).FormulaA1 = "=SUM(A1:A10)";
Run Code Online (Sandbox Code Playgroud)
只有在我直接在 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$2&\"*\")*(MAX($G$4: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)))))";
Run Code Online (Sandbox Code Playgroud)
我已经检查/尝试过:
SUM()或FIND()- >(-sum作品,找不工作)Excel中显示我: 图片1
这是: 图片2
图 2 中的 Linked 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>
Run Code Online (Sandbox Code Playgroud)
您不能使用分号 ( ;) 来分隔 closedxml 中的参数。,像这样使用逗号():
indexSheet.Cell("G" + cellIndex).FormulaA1 = "=FIND(\"erw\",H5)";
Run Code Online (Sandbox Code Playgroud)
这就是为什么SUM(range)有效但FIND(find_text;within_text)不起作用的原因......