c# - EPPlus SUMIFS 返回值 #VALUE
问题描述
我正在用 EPPlus 生成 excel 文件。最后,我尝试获取列的值总和,但得到#VALUE!
我首先使用了 SUM 公式,但得到了同样的错误。这是一个示例代码。
for (int x = 2; x <= totalIteration; x++)
{
startperiodletter = ColumnIndexToColumnLetter(x) + 2;
endperiodletter = ColumnIndexToColumnLetter(x) + totalrows;
tmpCell = ColumnIndexToColumnLetter(x) + (totalrows+1);
ws.Cells[tmpCell].Formula = "=SUMIFS(B2:B99,B2:B99,>0)";
ws.Cells[tmpCell].Calculate();
val = (ws.Cells[tmpCell].Value == null ? "" : ws.Cells[tmpCell].Value.ToString());
}
ws.Cells[tmpCell].Formula = "=SUMIFS(B2:B99,B2:B99,>0)"; 通过这种方式,我将SUMIF 公式与 EPPLus 一起使用,当我尝试读取值时,会得到像#VALUE 这样的值!我以这种方式读取值val = (ws.Cells[tmpCell].Value == null ? "" : ws.Cells[tmpCell].Value.ToString());
这条线没有按预期工作。我的几个单元格是空的,我想得到那些不为空的单元格值的总和。
请纠正我在上面的代码中犯的错误。
解决方案
推荐阅读
- firebase - 如何连接 react native saga 以响应原生 firebase
- r - 用 r 创建一个伪随机列表
- mysql - Java 中的 SQLSyntaxErrorException。奇怪的问题
- vb.net - 从子程序返回多条记录并解析成数据表 [Unidata][U2.NET]
- python - 以有组织的方式从网站获取信息
- python - asyncio + asyncpg + pandas:从 db 中获取带有异步选择的 pandas.df - 错误
- c# - 无法隐式转换类型 System.Collections.Generic.List
到 System.Collections.Generic.List - javascript - jQuery拖放适用于文件,但不适用于文件夹
- django - 推荐系统的 Models.py
- google-street-view - 谷歌街景全景之间的多个箭头标记问题