我正在使用电子表格库来访问 excel 文件。
如何通过扩展方法和 lambda 表达式缩短以下构造?我想用布尔值计算所有单元格。
Dictionary<int, Dictionary<int, SLCell>> cells = sl.GetCells();
int nCount = 0;
foreach (Dictionary<int, SLCell> Value in cells.Values)
{
foreach (SLCell Cell in Value.Values)
{
if (Cell.DataType == CellValues.Boolean)
{
nCount++;
}
}
}