From 3fe6f77d248db9b945e3111ce6ecaab5d1a039ec Mon Sep 17 00:00:00 2001 From: KarlKallman Date: Mon, 29 Jun 2026 10:35:40 +0200 Subject: [PATCH 1/2] Allow AppVersion in OfficeProperties to be set to null. #2393. --- src/EPPlus/OfficeProperties.cs | 8 ++++++++ src/EPPlusTest/OfficePropertiesTests.cs | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/EPPlus/OfficeProperties.cs b/src/EPPlus/OfficeProperties.cs index 210483766f..39c01c4596 100644 --- a/src/EPPlus/OfficeProperties.cs +++ b/src/EPPlus/OfficeProperties.cs @@ -293,6 +293,14 @@ public string AppVersion get { return _extendedHelper.GetXmlNodeString(AppVersionPath); } set { + if (value == null) + { + if(_extendedHelper.TopNode != null) + { + _extendedHelper.DeleteNode(AppVersionPath); + } + return; + } var versions = value.Split('.'); if(versions.Length!=2 || versions.Any(x=>!x.IsInt())) { diff --git a/src/EPPlusTest/OfficePropertiesTests.cs b/src/EPPlusTest/OfficePropertiesTests.cs index 2ac4cc6657..17bf6342f8 100644 --- a/src/EPPlusTest/OfficePropertiesTests.cs +++ b/src/EPPlusTest/OfficePropertiesTests.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using OfficeOpenXml; +using OfficeOpenXml.FormulaParsing.Excel.Functions.DateAndTime; using System; using System.Collections.Generic; using System.Linq; @@ -58,5 +59,19 @@ public void ValidateCaseInsensitiveCustomProperties_Loading() p.Dispose(); p2.Dispose(); } + + [TestMethod] + public void AppVersion_SetToNull_RemovesNodeWithoutThrowing() + { + using var package = new ExcelPackage(); + var props = package.Workbook.Properties; + var s = package.Workbook.Worksheets.Add("TestSheet"); + s.Cells["A1"].Value = "Hej"; + props.AppVersion = "16.0300"; + Assert.AreEqual("16.0300", props.AppVersion); + + props.AppVersion = null; + Assert.IsTrue(string.IsNullOrEmpty(props.AppVersion)); + } } } From efede534c078d686ce50f8f8a6a7ea22e9df960d Mon Sep 17 00:00:00 2001 From: KarlKallman Date: Fri, 3 Jul 2026 13:54:55 +0200 Subject: [PATCH 2/2] WIP --- .../Excel/Functions/RefAndLookup/Filter.cs | 14 +++++++++++-- .../Functions/RefAndLookup/FilterTests.cs | 21 +++++++++++++++++++ .../Issues/FormulaCalculationIssues.cs | 13 ++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/EPPlus/FormulaParsing/Excel/Functions/RefAndLookup/Filter.cs b/src/EPPlus/FormulaParsing/Excel/Functions/RefAndLookup/Filter.cs index 829edc6e55..19fd0a7647 100644 --- a/src/EPPlus/FormulaParsing/Excel/Functions/RefAndLookup/Filter.cs +++ b/src/EPPlus/FormulaParsing/Excel/Functions/RefAndLookup/Filter.cs @@ -137,13 +137,23 @@ private static CompileResult FilterOnColumn(IRangeInfo arg1, IRangeInfo arg2, Fu var checkDimension = !arg2.IsInMemoryRange; var fc = arg2.Address.FromCol; var dfc = arg2.Dimension.FromCol; - for (int c = 0; c < s2.NumberOfCols; c++) + var columns = s2.NumberOfCols == 1 ? s1.NumberOfCols : s2.NumberOfCols; + for (int c = 0; c < columns; c++) { if (checkDimension && fc + c > dfc) { break; } - var boolValue = ConvertUtil.GetValueDouble(arg2.GetOffset(0, c), false, true); + int boolIx; + if(s2.NumberOfCols == 1) + { + boolIx = 0; + } + else + { + boolIx = c; + } + var boolValue = ConvertUtil.GetValueDouble(arg2.GetOffset(0, boolIx), false, true); if (double.IsNaN(boolValue)) { return CompileResult.GetDynamicArrayResultError(eErrorType.Value); diff --git a/src/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/FilterTests.cs b/src/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/FilterTests.cs index 5b3e78297c..6c248e1e75 100644 --- a/src/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/FilterTests.cs +++ b/src/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/FilterTests.cs @@ -83,5 +83,26 @@ public void FilterShouldHandleNAAsIfEmptyValue() Assert.AreEqual("Joe", s.Cells["C1"].Value); } } + + [TestMethod] + public void Filter_SingleColumnInclude_BroadcastsAcrossAllValueColumns() + { + using (var package = new ExcelPackage()) + { + var s = package.Workbook.Worksheets.Add("test"); + + s.Cells["A1"].Value = "GL-40010 - Office Supplies"; + s.Cells["B1"].Value = 4520.75d; + s.Cells["C1"].Value = "Not Posted"; + + s.Cells["E1"].Formula = "FILTER(A1:B1, C1 <> \"Posted!\", 0)"; + s.Calculate(); + + Assert.AreEqual("GL-40010 - Office Supplies", s.Cells["E1"].Value, + "Label-kolumnen ska behållas."); + Assert.AreEqual(4520.75d, s.Cells["F1"].Value, + "Beloppskolumnen ska också behållas via broadcast."); + } + } } } diff --git a/src/EPPlusTest/Issues/FormulaCalculationIssues.cs b/src/EPPlusTest/Issues/FormulaCalculationIssues.cs index 149b54db18..5405496ea3 100644 --- a/src/EPPlusTest/Issues/FormulaCalculationIssues.cs +++ b/src/EPPlusTest/Issues/FormulaCalculationIssues.cs @@ -1679,6 +1679,19 @@ public void s1054() Assert.AreEqual(1258679d, result); } } + + [TestMethod] + public void s1060() + { + using (var p = OpenTemplatePackage("s1060.xlsx")) + { + var ws = p.Workbook.Worksheets[0]; + ws.Cells["A12"].Calculate(); + var result = ws.Cells["A13"].Value; + Assert.AreEqual(4520.75, result); + } + } + } }