hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

[Bug]: Named Expressions don't update when adding rows

Open grahamorrell opened this issue 9 months ago • 1 comments

Description

When adding rows using hf.AddRows( ) any formulae that are affected are automatically updated, matching the behaviour of Excel.

However any named expressions are not updated, meaning the ranges they point to are now incorrect.

Full reproduction in stackblitz link below

Video or screenshots

Image

Demo

https://stackblitz.com/edit/node-sfv4nvjp?file=index.ts

HyperFormula version

3.0.0

Your framework

Node

Your environment

N/A

grahamorrell avatar Mar 03 '25 18:03 grahamorrell

Hi @grahamorrell, thanks for reaching out.

I verified that Microsoft Excel updates the named expression when a row is added in the middle of the referenced range. In that case, it must be considered a HyperFormula bug. I'm adding it to our backlog.

sequba avatar Mar 14 '25 10:03 sequba

@grahamorrell, I analyzed your demo again and found that the way you defined a named expression was a bit off.

hf.addNamedExpression('testName', 'Sheet1!A1:A2');

This definition lacks the equals sign (=), so it is not a formula that refers to a range but a plain string value "Sheet1!A1:A2".

The correct definition of a named expression that refers to a range would look like this:

hf.addNamedExpression('testName', '=Sheet1!$A$1:$A$2');

When I changed it in your demo, it works as expected: https://stackblitz.com/edit/node-kpsf83i8?file=index.ts

I'm sorry I didn't spot it when I first looked at this issue.

sequba avatar Oct 14 '25 13:10 sequba