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.Math
|
---|
8 | {
|
---|
9 | public class Large : ExcelFunction
|
---|
10 | {
|
---|
11 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
12 | {
|
---|
13 | ValidateArguments(arguments, 2);
|
---|
14 | var args = arguments.ElementAt(0);
|
---|
15 | var index = ArgToInt(arguments, 1) - 1;
|
---|
16 | var values = ArgsToDoubleEnumerable(new List<FunctionArgument> {args}, context);
|
---|
17 | ThrowExcelErrorValueExceptionIf(() => index < 0 || index >= values.Count(), eErrorType.Num);
|
---|
18 | var result = values.OrderByDescending(x => x).ElementAt(index);
|
---|
19 | return CreateResult(result, DataType.Decimal);
|
---|
20 | }
|
---|
21 | }
|
---|
22 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.