mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #435] Issue when using constant memory with merge range #341
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#341
Loading…
Add table
Add a link
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 @tritueviet on GitHub (Mar 12, 2024).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/435
I am using libxlsxwriter to do export excel has a lot of merge cell range with constant memory support, but it not working because it not supported.
Here is some code that demonstrates the problem:
`#include "xlsxwriter.h"
int main() {
lxw_workbook_options options = {.constant_memory = LXW_TRUE,
.tmpdir = NULL,
.use_zip64 = LXW_FALSE,
.output_buffer = NULL,
.output_buffer_size = NULL};
lxw_workbook *workbook = workbook_new_opt("merge_range.xlsx", &options);
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_format *merge_format = workbook_add_format(workbook);
}
`
Can you support this function in constant memory?
@tritueviet commented on GitHub (Apr 4, 2024):
any update?
@jmcnamara commented on GitHub (Apr 4, 2024):
I don't plan to implement this feature. Constant memory mode writes data row by row for efficiency and
merge_range()needs to write data on (usually) several rows so they aren't compatible.I'll explain why in case anyone want to try fix it in their own version but I won't upstream it.
Consider a simple worksheet with a merged area like this:
This is stored in an Excel xlsx file with the following xml:
The main thing to understand from this is that the merged range is stored in 2 places/ways:
<mergeCells>element.<c>elements which are mainly blank and which have the same cell style propertys="1"as the first cell in the merged range which contains the string/number for the merged cells.When writing a file in
constant_memorymode it is possible to write the elements in the first but the elements in the second require the row number/cursor to advance which means that data cannot be written in the previous rows.So that breaks merged ranges or else breaks writing any other data in a section of the worksheet with a merged range.
It would be possible to workaround this by tracking the merged ranges and then as the row/cursor advances to write out the formatted cells. However, I don't intend to add this to the library since it is reasonable amount of work to implement in a non error prone way. Also, and this is as important as the technical/effort reason, the constant memory mode is mainly intended for cases where the user wants to dump a large amount of data in a memory efficient way and in that mode they need to compromise on features such as merged ranges and tables.
So I am going to close this as won't fix.