Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RemoveBackwardsCompatibility/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/FormulaParsing/Excel/Functions/Information/IsErr.cs @ 18242

Last change on this file since 18242 was 12074, checked in by sraggl, 9 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using OfficeOpenXml.FormulaParsing.ExpressionGraph;
6
7namespace 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.