-
Notifications
You must be signed in to change notification settings - Fork 304
Description
EPPlus usage
Commercial use (I have a commercial license)
Environment
Windows 11
Epplus version
8.4.2
Spreadsheet application
Excel (Office 365)
Description
Hello,
it seems that the double unary operator (--) does not correctly coerce values when applied to dynamic array expressions.
Example
Consider the following worksheet:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | TRUE | =A1 | =--(A1) | =A1:A2 | =--(A1:A2) |
| 2 | FALSE | =A2 | =--(A2) |
After calling Calculate() on the Workbook, the following results are produced:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | TRUE | TRUE | 1 | TRUE | 0 |
| 2 | FALSE | FALSE | 0 | FALSE | 0 |
Expected behavior
In Excel (Microsoft 365), the formula =--(A1:A2) (Column E) spills and evaluates to:
| E | ||
|---|---|---|
| 1 | ... | 1 |
| 2 | ... | 0 |
So cell E1 should contain 1, not 0.
The double unary operator works correctly for scalar values (=--(A1) and =--(A2)), but does not behave correctly when applied to a range/dynamic array expression.
Question
Is the double unary operator officially supported by the formula engine?
It is not listed as a function in the documentation, but the attached logger does not indicate that it is unsupported either.
Code
using var package = new ExcelPackage(new FileInfo("example.xlsx"));
using var workbook = package.Workbook;
workbook.FormulaParserManager.AttachLogger(new FileInfo("example_log.txt"));
workbook.Calculate();
package.SaveAs(new FileInfo("example_new.xlsx"));Log
=================================
Timestamp: 25.02.2026 08:50:04
Starting formula calculation.
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!B1 True Boolean
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!C1 1 Decimal
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!D1 OfficeOpenXml.FormulaParsing.Ranges.RangeInfo ExcelRange
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!E1 OfficeOpenXml.FormulaParsing.Ranges.InMemoryRange ExcelRange
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!B2 False Boolean
=================================
Timestamp: 25.02.2026 08:50:04
Set value in Cell Sheet1!C2 0 Decimal
=================================
Timestamp: 25.02.2026 08:50:04
Calculation done...number of cells parsed: 8
Thank you for your help.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status