Skip to content

fix: a sheet name that begins with digits is lexed as a number and a name - #62

Open
gthb wants to merge 2 commits into
borgar:masterfrom
gthb:lex-digit-leading-sheet-name
Open

fix: a sheet name that begins with digits is lexed as a number and a name#62
gthb wants to merge 2 commits into
borgar:masterfrom
gthb:lex-digit-leading-sheet-name

Conversation

@gthb

@gthb gthb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

2020plan!A1 lexes as the number 2020 followed by the reference plan!A1, so a sheet whose name begins with digits is not read as a prefix at all. Excel reads 2020plan as the sheet name and stores it quoted, '2020plan'!A1. parseA1Ref already reads one prefix; only the formula lexers disagreed. The number lexer declines when a ! or : directly follows the digits, which is what makes 1!A1 and 1:5!A1 work, but did not look past the name characters between.

lexNumber now declines when the digits run on into sheet-name characters that end at a ! or :, leaving the position to the name and prefix lexers. 2020plan on its own is still the number 2020 and the name plan.

2020plan!A1 lexed as the number 2020 followed by plan!A1, so a sheet whose
name begins with digits was not read as a prefix at all. The number lexer
already declines when a "!" or ":" follows the digits directly, which is
what makes 1!A1 and 1:5!A1 work; it did not look past the name characters
between them.

Digits that run on into name characters and then reach a "!" or ":" are now
left to the name and prefix lexers. A number followed by a name that is not
a prefix is unaffected, so 2020plan on its own is still the number 2020 and
the name plan.
lexContextUnquoted already tested the set of characters an unquoted sheet
name may contain, inline. The number lexer's new check transcribed that
set into its own isNameChar. Extract the test into
isUnquotedSheetNameChar in lexContext.ts and use it from both, so the
set is defined once.

The name says sheet name rather than context because the test only ever
applies to that part of a prefix: the bracketed workbook name is exempt
from it, and a path cannot appear unquoted.
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