Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using OfficeOpenXml.FormulaParsing.Exceptions;
|
---|
6 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
7 | using OfficeOpenXml.Utils;
|
---|
8 |
|
---|
9 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions.Information
|
---|
10 | {
|
---|
11 | public class N : ExcelFunction
|
---|
12 | {
|
---|
13 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
14 | {
|
---|
15 | ValidateArguments(arguments, 1);
|
---|
16 | var arg = GetFirstValue(arguments);
|
---|
17 |
|
---|
18 | if (arg is bool)
|
---|
19 | {
|
---|
20 | var val = (bool) arg ? 1d : 0d;
|
---|
21 | return CreateResult(val, DataType.Decimal);
|
---|
22 | }
|
---|
23 | else if (IsNumeric(arg))
|
---|
24 | {
|
---|
25 | var val = ConvertUtil.GetValueDouble(arg);
|
---|
26 | return CreateResult(val, DataType.Decimal);
|
---|
27 | }
|
---|
28 | else if (arg is string)
|
---|
29 | {
|
---|
30 | return CreateResult(0d, DataType.Decimal);
|
---|
31 | }
|
---|
32 | else if (arg is ExcelErrorValue)
|
---|
33 | {
|
---|
34 | return CreateResult(arg, DataType.ExcelError);
|
---|
35 | }
|
---|
36 | throw new ExcelErrorValueException(eErrorType.Value);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.