Skip to content

xlsx: fix shared formula expansion corrupting function names#645

Open
cilladev wants to merge 4 commits intotafia:masterfrom
cilladev:fix/shared-formula-function-names
Open

xlsx: fix shared formula expansion corrupting function names#645
cilladev wants to merge 4 commits intotafia:masterfrom
cilladev:fix/shared-formula-function-names

Conversation

@cilladev
Copy link
Copy Markdown

Fixes #644.

What

replace_cell_names() treats LOG10 as a cell reference (column LOG = #8509, row 10) and applies the row offset during shared formula expansion. This produces LOG11, LOG12, ..., LOG19 for subsequent rows.

Why

Reference::parse() accepts LOG10 because LOG is a valid Excel column name (within the 16,384 column limit) and 10 is a valid row number. The tokenizer in replace_cell_names() cannot distinguish function names from cell references.

How

Skip tokens immediately followed by ( — in Excel formula syntax, a ( after an alphanumeric token always means function call, never cell reference.

Testing

$ cargo run --example try
# Before: row 1 shows LOG11, row 2 shows LOG12, ...
# After:  all rows show LOG10

Test file (log10_shared.xlsx) attached to #644.

`replace_cell_names()` treated `LOG10` as a cell reference (column LOG,
row 10) and offset the row, producing LOG11, LOG12, etc. Skip tokens
immediately followed by `(` — those are function calls, not cell refs.
Collapse `if` into outer `match` arms (collapsible_match) and replace
explicit loop counter with iterator zip (explicit_counter_loop).
@jmcnamara
Copy link
Copy Markdown
Collaborator

Thanks. Could you also add a test case to the tests/test.rs file with the sample xls file that demonstrates the issue.

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.

Bug: shared formula expansion corrupts function names that parse as valid cell references (e.g., LOG10 -> LOG11)

2 participants