Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
6 |
|
---|
7 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions.Information
|
---|
8 | {
|
---|
9 | public class IsErr : ErrorHandlingFunction
|
---|
10 | {
|
---|
11 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
12 | {
|
---|
13 | var isError = new IsError();
|
---|
14 | var result = isError.Execute(arguments, context);
|
---|
15 | if ((bool) result.Result)
|
---|
16 | {
|
---|
17 | var arg = GetFirstValue(arguments);
|
---|
18 | if (arg is ExcelDataProvider.IRangeInfo)
|
---|
19 | {
|
---|
20 | var r = (ExcelDataProvider.IRangeInfo)arg;
|
---|
21 | var e=r.GetValue(r.Address._fromRow, r.Address._fromCol) as ExcelErrorValue;
|
---|
22 | if (e !=null && e.Type==eErrorType.NA)
|
---|
23 | {
|
---|
24 | return CreateResult(false, DataType.Boolean);
|
---|
25 | }
|
---|
26 | }
|
---|
27 | else
|
---|
28 | {
|
---|
29 | if (arg is ExcelErrorValue && ((ExcelErrorValue)arg).Type==eErrorType.NA)
|
---|
30 | {
|
---|
31 | return CreateResult(false, DataType.Boolean);
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 | return result;
|
---|
36 | }
|
---|
37 |
|
---|
38 | public override CompileResult HandleError(string errorCode)
|
---|
39 | {
|
---|
40 | return CreateResult(true, DataType.Boolean);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.