Line | |
---|
1 | using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
|
---|
2 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Text;
|
---|
7 |
|
---|
8 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions.Math
|
---|
9 | {
|
---|
10 | public class CountBlank : ExcelFunction
|
---|
11 | {
|
---|
12 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
13 | {
|
---|
14 | ValidateArguments(arguments, 1);
|
---|
15 | var arg = arguments.First();
|
---|
16 | if(!arg.IsExcelRange)throw new InvalidOperationException("CountBlank only support ranges as arguments");
|
---|
17 | var result = arg.ValueAsRangeInfo.GetNCells();
|
---|
18 | foreach (var cell in arg.ValueAsRangeInfo)
|
---|
19 | {
|
---|
20 | if (!(cell.Value == null || cell.Value == string.Empty))
|
---|
21 | {
|
---|
22 | result--;
|
---|
23 | }
|
---|
24 | }
|
---|
25 | return CreateResult(result, DataType.Integer);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.