File tree Expand file tree Collapse file tree
EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup
EPPlus/FormulaParsing/Excel/Functions/RefAndLookup Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Date Author Change
1414using System . Collections . Generic ;
1515using System . Linq ;
1616using System . Text ;
17+ using OfficeOpenXml . Export . HtmlExport ;
1718using OfficeOpenXml . FormulaParsing . Excel . Functions . MathFunctions ;
1819using OfficeOpenXml . FormulaParsing . Excel . Functions . Metadata ;
1920using OfficeOpenXml . FormulaParsing . Exceptions ;
@@ -184,5 +185,14 @@ public override string NamespacePrefix
184185 /// If the function is allowed in a pivot table calculated field
185186 /// </summary>
186187 public override bool IsAllowedInCalculatedPivotTableField => false ;
187- }
188+
189+ public override ExcelFunctionParametersInfo ParametersInfo => new ExcelFunctionParametersInfo ( new Func < int , FunctionParameterInformation > ( ( argumentIndex ) =>
190+ {
191+ if ( argumentIndex == 2 )
192+ {
193+ return FunctionParameterInformation . IgnoreErrorInPreExecute ;
194+ }
195+ return FunctionParameterInformation . Normal ;
196+ } ) ) ;
197+ }
188198}
Original file line number Diff line number Diff line change @@ -67,5 +67,21 @@ public void ShouldFilterOnColumn()
6767 Assert . AreEqual ( 4 , _ws . Cells [ "D2" ] . Value ) ;
6868 Assert . AreEqual ( 1 , _ws . Cells [ "D3" ] . Value ) ;
6969 }
70+
71+ [ TestMethod ]
72+ public void FilterShouldHandleNAAsIfEmptyValue ( )
73+ {
74+ using ( var package = new ExcelPackage ( ) )
75+ {
76+ var s = package . Workbook . Worksheets . Add ( "test" ) ;
77+ s . Cells [ "A1" ] . Value = "Joe" ;
78+ s . Cells [ "A2" ] . Value = "Anna" ;
79+ s . Cells [ "B1" ] . Value = 1 ;
80+ s . Cells [ "B2" ] . Value = 2 ;
81+ s . Cells [ "C1" ] . Formula = "FILTER(A1:A2, B1:B2 =1, NA())" ;
82+ s . Calculate ( ) ;
83+ Assert . AreEqual ( "Joe" , s . Cells [ "C1" ] . Value ) ;
84+ }
85+ }
7086 }
7187}
You can’t perform that action at this time.
0 commit comments