Handle the * fill operator in custom number format detection#667
Open
greymoth-jp wants to merge 2 commits into
Open
Handle the * fill operator in custom number format detection#667greymoth-jp wants to merge 2 commits into
* fill operator in custom number format detection#667greymoth-jp wants to merge 2 commits into
Conversation
…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.
jmcnamara
requested changes
Jun 26, 2026
| match (s, escaped, is_quote, ap, brackets) { | ||
| (_, true, ..) => escaped = false, // if escaped, ignore | ||
| ('_' | '\\', ..) => escaped = true, | ||
| // `\` escapes, `_` skips a character's width, and `*` repeats the |
Collaborator
There was a problem hiding this comment.
Reduce this down to a single line instructive comment.
Author
|
Trimmed to a single line as suggested. |
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.
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 asDateTimeand a number cell is reported as a date.This sits in the same
matchthat #665 just hardened for quote handling;*was the remaining unhandled case. The fix adds'*'to the existing escape arm.Verified both ways:
#,##0*yreturnsDateTimebefore the fix andOtherafter;*-yyyy-mm-ddstill correctly returnsDateTime. All 24 existing format tests are unchanged andcargo test --libpasses 42/42.