Skip to content

Handle the * fill operator in custom number format detection#667

Open
greymoth-jp wants to merge 2 commits into
tafia:masterfrom
greymoth-jp:fix/format-star-fill-operator
Open

Handle the * fill operator in custom number format detection#667
greymoth-jp wants to merge 2 commits into
tafia:masterfrom
greymoth-jp:fix/format-star-fill-operator

Conversation

@greymoth-jp

Copy link
Copy Markdown

detect_custom_number_format (src/formats.rs) — the number-format classifier shared by xlsx, xlsb and xls — treats \ and _ as "escape the next char" but does not handle Excel's * fill operator. With *c, the character after * is a literal used to pad the cell, so a numeric format whose fill char is a date letter, e.g. #,##0*y, is misread as DateTime and a number cell is reported as a date.

This sits in the same match that #665 just hardened for quote handling; * was the remaining unhandled case. The fix adds '*' to the existing escape arm.

Verified both ways: #,##0*y returns DateTime before the fix and Other after; *-yyyy-mm-dd still correctly returns DateTime. All 24 existing format tests are unchanged and cargo test --lib passes 42/42.

…mat detection

The `*` (fill/repeat) operator in an Excel number format repeats the
single character that follows it to fill the cell width, so that
character is a literal, exactly like the char after `\` or `_`.
`detect_custom_number_format` did not account for `*`, so when the fill
character happened to be a date letter (e.g. `#,##0*y`) it was mistaken
for a date token and a numeric cell was reported as a DateTime.

Add `*` to the escape arm and cover it with regression tests.
Comment thread src/formats.rs Outdated
match (s, escaped, is_quote, ap, brackets) {
(_, true, ..) => escaped = false, // if escaped, ignore
('_' | '\\', ..) => escaped = true,
// `\` escapes, `_` skips a character's width, and `*` repeats the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce this down to a single line instructive comment.

@jmcnamara jmcnamara self-assigned this Jun 26, 2026
@jmcnamara jmcnamara added bug next_release awaiting user changes Awaiting changes to a PR to fix requested changes or CI issues. labels Jun 26, 2026
@greymoth-jp

Copy link
Copy Markdown
Author

Trimmed to a single line as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting user changes Awaiting changes to a PR to fix requested changes or CI issues. bug next_release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants