mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-10-23 08:07:32 -06:00
[GH-ISSUE #521] Feature request: Optionally hide the rows an autofilter excludes #519
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#519
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/521
What
An opt-in way to have libxlsxwriter hide the rows a filter excludes, rather
than requiring every caller to reimplement Excel's matching rules.
I want to be clear this is a request to revisit a deliberate decision, not a bug
report. The header documents the current contract four times, e.g.
worksheet.h:4204:Why it might be worth revisiting
Excel does not apply a filter when a file is opened, so criteria alone produce
a sheet that shows the funnel icon set and every row visible — it looks filtered
and is not. Every binding therefore has to reimplement the matching rules, and
they are much subtler than they look.
Adding this to writexl took three rounds of measuring Excel's actual behaviour,
and two of my implementations were wrong in ways that produced plausible files.
Measured by writing criteria with no rows hidden, opening in Excel and pressing
Data → Reapply so Excel computed each match itself:
The rules are a property of the XML form, not the criteria. From
_set_custom_filter(),==without a wildcard andblanksbecome a<filters>value list; everything else becomes<customFilters>. Excel matchesthose two by entirely different rules:
<filters>value list<customFilters>*/?wildcardsConsequences that are not guessable from the criteria alone:
== "10"keeps the number10— a value list ignores how the cell is stored.== "1*"keeps nothing on a numeric column: the wildcard flips the samecriteria into a typed comparison, and no number is text.
!= 10and!= "10"writeidentical XML, so Excel parses
val="10"as a number either way.!=true for it.!=and no other comparison — even thoughnon-blanksisitself written as
notEqual val=" ".Only the last of these is at all discoverable from the file format.
Suggested shape
Opt-in, so nothing changes for existing callers:
or a field on an options struct.
constant_memorymode need not be an obstacle: when the filter is set beforethe rows are written, the decision can be made per row as it is streamed, which
is the same point
worksheet_write_row()already decides everything else.What I can contribute
The 27 measured cases behind the table above, as a test corpus — the workbooks,
the criteria, and what Excel actually did with each. Happy to supply them in
whatever form is useful, or to attempt a PR if the direction is welcome.
@jmcnamara commented on GitHub (Jul 29, 2026):
The Rust version of this library
rust_xlsxwriterdoes that. However, I am unlikely to add it to the C version due to the work involved.Having said that, if you are implementing filtering from a Dataframe language like R then you already have an equivalent filtering language that you use to figure out which rows should be hidden. This could be something that you could implement in
writexlwithout any changes inlibxlsxwriter.Closing as won't fix/not planned.
@billdenney commented on GitHub (Jul 29, 2026):
Yes, I already implemented it on the R side. I was thinking it could be of general interest. Makes sense.