mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-10-23 08:07:32 -06:00
[GH-ISSUE #522] constant_memory silently drops all but the first cell of a multi-cell array formula #521
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/libxlsxwriter#521
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @billdenney on GitHub (Jul 28, 2026).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/522
With
constant_memoryenabled, a multi-cell array formula writes only itstop-left cell. The
refattribute still declares the full range, so the fileclaims a result that most of the cells do not contain.
worksheet_write_array_formula()returnsLXW_NO_ERROReither way.Excel opens the file without complaint — it recalculates the array on load and
fills the missing cells — so the problem is invisible if Excel is the only
consumer. It shows up when something reads the stored cells instead of
recalculating them: readxl, pandas, and anything else parsing the sheet
directly see a one-cell result where a three-cell one was declared. A pipeline
that reads such a file and writes it back out, never passing through Excel,
loses the array's extent silently.
Cause
_store_array_formula()(worksheet.c:8163):The same guard also means a
formatpassed for the range is applied only tothe top-left cell.
Reproducer
normal.xlsx:constant.xlsx:Why this may be awkward to fix, and a smaller ask
I appreciate the padding is not simply an oversight: in streaming mode the rows
below the current one have not been reached, so they cannot be written at the
time of the call without buffering or deferring.
If padding in optimize mode is out of scope, the smaller fix would be to stop
returning success. libxlsxwriter already has the precedent —
worksheet_add_table()refuses outright in this mode:A multi-cell array formula (
last_row > first_row || last_col > first_col)degrading silently rather than warning is the part that made this hard to find.
Single-cell array formulas are unaffected and could keep working.
Found while adding array-formula support to writexl (R), which now turns
constant_memoryoff whenever a multi-cell array range is present. Version1.2.4.
@jmcnamara commented on GitHub (Jul 29, 2026):
I think this one is just going to have to be a known (or unknown) limitation.
Again, the Rust version of the library handles this correctly in constant memory mode since it does a form of caching for array formula and table data that are outside the current row and then adds them as the row is being written. This is technically possible in the C version but fiddly and unlikely to be implemented.
I think your workaround of not using the
constant_memorywhen multi-cell array range is present is probably best. In fact you should probably consider not using it at all since you are going to run into other potential issues like this.Closing as won't fix.