-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathTrimRange.cs
More file actions
50 lines (44 loc) · 2.19 KB
/
Copy pathTrimRange.cs
File metadata and controls
50 lines (44 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*************************************************************************************************
Required Notice: Copyright (C) EPPlus Software AB.
This software is licensed under PolyForm Noncommercial License 1.0.0
and may only be used for noncommercial purposes
https://polyformproject.org/licenses/noncommercial/1.0.0/
A commercial license to use this software can be purchased at https://epplussoftware.com
*************************************************************************************************
Date Author Change
*************************************************************************************************
25/5/2026 EPPlus Software AB EPPlus v8.6
*************************************************************************************************/
using OfficeOpenXml.FormulaParsing.Excel.Functions.Metadata;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup.TrimFunctions;
using OfficeOpenXml.FormulaParsing.FormulaExpressions;
using System.Collections.Generic;
namespace OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup
{
[FunctionMetadata(
Category = ExcelFunctionCategory.LookupAndReference,
EPPlusVersion = "8",
Description = "Excludes all empty rows and/or columns from the outer edges of a range")]
internal class TrimRange : TrimFunctionsBase
{
public override string NamespacePrefix => "_xlfn.";
public override CompileResult Execute(IList<FunctionArgument> arguments, ParsingContext context)
{
var rowMode = TrimMode.Both;
var colMode = TrimMode.Both;
if (arguments.Count > 1)
{
var v = ArgToInt(arguments, 1, RoundingMethod.Convert);
if (v < 0 || v > 3) return CompileResult.GetErrorResult(eErrorType.Value);
rowMode = (TrimMode)v;
}
if (arguments.Count > 2)
{
var v = ArgToInt(arguments, 2, RoundingMethod.Convert);
if (v < 0 || v > 3) return CompileResult.GetErrorResult(eErrorType.Value);
colMode = (TrimMode)v;
}
return ExecuteTrim(arguments, rowMode, colMode, context);
}
}
}