Repository navigation
xlsx: keep a table's filter criteria when the sheet AutoFilter coincides with it - #1531
Merged
aiongg merged 1 commit intoOct 22, 2026
Merged
Conversation
…des with it The engine's live filter state is always sheet.autofilter — apply_filter, filter_values, clear_filter, reapply and the slicer command all read and write it, and a table's header dropdown installs one over the table's own range — while Table::filter is only ever filled by the reader. Writing suppressed the sheet <autoFilter> whenever any table merely intersected it and wrote the table part from Table::filter, which was empty: a filtered table saved with its rows still hidden and no criteria anywhere, so on reopen there was no filter to clear and Excel showed an inactive filter over mysteriously hidden rows. A slicer's selection was lost the same way. Fold the coinciding sheet filter's criteria into the table part (colId offsets are relative to the range's first column, and both ranges start at the same column, so they carry over verbatim); a filter that only partially covers a table still has nowhere valid to go and keeps being suppressed. Regression test: a_table_filter_criteria_survive_a_round_trip — on main the table part carries no criteria after a save; with the fold they round trip, the hidden row stays, and the sheet keeps no duplicate autoFilter.
This was referenced Oct 15, 2026
|
Verified against
Correct fix for a real silent-data-loss bug; just needs a |
aiongg
added a commit
to aiongg/gridcraft
that referenced
this pull request
Oct 22, 2026
…hen both start at the same column A sheet AutoFilter that starts right of the table's first column is not folded (its colId offsets would hit the wrong column); the sheet autoFilter stays suppressed for any table it intersects, as before. Test added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The engine's live filter state is always
sheet.autofilter—apply_filter(data.rs:585),filter_values,clear_filter,reapplyandcmd/slicer.rsall read and write it, and the auto-filter dropdown of a table header installs one over the table's own range (ui-egui/src/grid.rs:2749runsdata.filter {"range": <the table's range>}) — whileTable::filteris only ever filled by the XLSX reader. Writing then suppressed the sheet<autoFilter>whenever any table merely intersected it (sheet_write.rs:342) and wrote the table part fromTable::filter, which is empty: a filtered table saved with its rows stillhidden="1"and no filter criteria anywhere. On reopen there is no filter to clear, the dropdown shows no selection,data.clearFilterrestores nothing, and Excel shows an inactive filter over mysteriously hidden rows. A slicer's selection is discarded by the same path (a slicer is front-end over the same filter state).Fix: where the sheet filter's range coincides with a table's (contains, header row, filter button) and the table has no criteria of its own, fold the sheet criteria into the table part — the stored
colIdoffsets are relative to the range's first column and both ranges start at the same column, so they carry over verbatim. A sheet filter that only partially overlaps a table still has no valid home (an<autoFilter>beside the table's own would be invalid XML) and keeps being suppressed; the suppression test is narrowed fromintersectsto that case so partial filters are written as before.Regression test:
a_table_filter_criteria_survive_a_round_trip— on main the table part carries no criteria after a save (theexpect("…kept on save")fires); with the fold the criteria round trip, the hidden row stays hidden, and the sheet keeps no duplicate autoFilter. Fullgridcraft-xlsxlib suite green (174 passed).