Skip to content

Add --spreadsheet option to show column letters in the header - #207

Open
ChrisJr404 wants to merge 1 commit into
YS-L:mainfrom
ChrisJr404:spreadsheet-column-letters
Open

ChrisJr404 wants to merge 1 commit into
YS-L:mainfrom
ChrisJr404:spreadsheet-column-letters

Conversation

@ChrisJr404

Copy link
Copy Markdown

This adds an opt-in --spreadsheet flag that displays spreadsheet-style column letters (A, B, C, ..., Z, AA, ...) alongside the column names in the header, addressing #87.

The motivation from that issue is being able to refer to columns by letter the way you would in Excel or Google Sheets ("look at column Z"). When --spreadsheet is passed, each header cell is prefixed with its letter, e.g. [A] country, [B] population.

A few implementation notes:

  • The letters are derived from each column's original position in the file (origin_index), not its on-screen position, so they stay correct and stable when scrolling horizontally or when a columns filter is active.
  • The letter prefix is produced in the existing get_effective_column_name path, the same place the sort indicator is added, so it composes with sorting and flows through column-width computation with no changes to the layout/border rendering.
  • The option is off by default; nothing changes unless --spreadsheet is passed.

I went with prefixing the existing header row (rather than adding a separate letters row) to keep the change small and avoid touching the border/offset math, but I'm happy to adjust the presentation if you'd prefer something different.

Testing: added a rendered-buffer snapshot test (test_spreadsheet_column_letters) and a unit test for the letter conversion covering the A/Z/AA/ZZ/AAA boundaries. cargo test --features cli passes (108 tests), and cargo fmt --check and cargo clippy --features cli --lib are clean.

This adds an opt-in --spreadsheet flag that prefixes each header cell with
its spreadsheet-style column letter (A, B, C, ..., Z, AA, ...), so columns
can be referred to by letter the way they are in Excel or Google Sheets.

The letters are derived from each column's original position in the file
(origin_index), so they remain correct and stable when scrolling
horizontally or when a columns filter is active. The feature is off by
default and reuses the existing effective-column-name path, so it composes
with sort indicators and column width computation without any layout change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant