Posted 29 September 2026, 2:25 am EST
Hi,
We have a workbook with dynamic array formulas using MAP/REDUCE, LAMBDA and INDIRECT, and when it is saved using the library, System.InvalidOperationException “Stack empty.” is thrown. Microsoft Excel calculates and saves the same workbook without any problem.
In the workbook, each SumXX sheet sums the same cell on the sheets listed in C13:C1x with a formula like this:
=SUM(MAP(INDIRECT($D$13),LAMBDA(x,INDIRECT(“'”&x&“'!”&ADDRESS(ROW(),COLUMN())))))
Some of the listed sheets are also SumXX sheets with the same formula (nested up to 3 levels). Smaller workbooks with only one or two nested sheets do not reproduce the problem. Calling Workbook.Calculate() before Save() does not throw.
Please see attachment for reproduction (open the workbook and save it). We confirmed this with DS.Documents.Excel 8.1.5, 9.0.3 and 9.2.1 (.NET 8, Windows).
Stack trace:
System.InvalidOperationException: Stack empty.
at System.Collections.Generic.Stack 1.ThrowForEmptyStack()
at System.Collections.Generic.Stack 1.Pop()
at GrapeCity.Documents.Excel.xj.i(mu a)
at GrapeCity.Documents.Excel.xj.a(mu a)
at GrapeCity.Documents.Excel.xj.os(mu a)
at GrapeCity.Documents.Excel.Functions.gnt.bi(mu a, lk b)
at GrapeCity.Documents.Excel.xj.os(mu a)
...
at GrapeCity.Documents.Excel.Workbook.Save(String fileName)
Please help to resolve this issue. Thank you.
Regards
