mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-10-05 06:10:24 -06:00
[GH-ISSUE #520] lxw_table_column.format is ignored for data written by the caller #518
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#518
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/520
Originally assigned to: @jmcnamara on GitHub.
lxw_table_column.formatis documented inworksheet.has:but it is only applied to cells libxlsxwriter writes itself. Data written by
the caller before
worksheet_add_table()keeps no format, silently.column->formatis read in exactly two places:_write_column_function()(worksheet.c:1830) — the total-row cell_write_column_formula()(worksheet.c:1874) — a calculated column_write_table_column_data()never applies it to the rest of the range, so theusual way of building a table — write the data, then mark it as a table —
loses the format.
Reproducer
xl/worksheets/sheet1.xml:B2carries nosattribute;C2hass="1". Samelxw_format *, samestruct field, on adjacent columns of one table. The only difference is that
libxlsxwriter wrote
Cand the caller wroteB.In Excel the
calccolumn shows$3.00andpriceshows1.5.Suggested resolutions
Either would resolve it; the first matches the documented contract:
column->formatacross the column's data rows in_write_table_column_data(), as_write_column_formula()already does forthe cells it writes.
to say it applies only to columns libxlsxwriter writes (calculated columns
and the total row), so the limitation is discoverable.
Found while adding table support to writexl Version 1.2.4.
@jmcnamara commented on GitHub (Jul 29, 2026):
The other versions of this library in Python/Perl/Rust handle this correctly because the allow the table data to be passed as one of the table parameters so that data is written by the internal table functions and the format is applied.
This is also why the table formatting works for table formulas (like in column "calc") in
libxlsxwriterbecause the formula and the format are both known to the library at the time of writing.In order to get this to work with
libxlsxwriteryou also need to apply the format when you are writing the data:In this case applying the format to column would probably be better:
Note, you still need to apply the column format via
lxw_table_optionsfor strict correctness with Excel.This limitation should be documented. I will do that.