如何检查特定的SpreadsheetGear IRange是否包含值(=非空白单元格)?
在Excel中,我可以使用COUNTA函数,但在SpreadsheetGear中没有。
发布于 2013-10-29 00:54:28
SpreadsheetGear支持COUNTA函数。您可以将其作为公式的一部分直接输入到单元格中。或者您可以使用ISheet。EvaluateValue(...)方法来计算公式,而无需将公式实际输入到单元格中。示例:
// Count the number of non-empty cells in A1:A12 on the specified worksheet
double count = (double)worksheet.EvaluateValue("COUNTA(A1:A12)");您也可以使用SpreadsheeGear应用程序接口构建自己的计数例程。下面的代码可能是一个很好的起点:
int counter = 0;
foreach (IRange cell in worksheet.Cells["A1:A12"])
{
if (cell.ValueType != SpreadsheetGear.ValueType.Empty)
counter++;
}https://stackoverflow.com/questions/19636190
复制相似问题