You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strange preferences of Named Expression names #880
Adding Named Expression by hfInstance.addNamedExpression raises a error when the name ends with a number and there are no digits in the middle.
Steps to reproduce
E.g. adding named expression "Product1" raises the error, while "Line2Product1" does not. From an end-user point of view, these names are similar, and Excel supports both of them.
Your environment
HyperFormula version: 1.3.0
Hint
See the strange regular expression in NamedExpressions.js line 243 (isNameValid function)
Expressions should limit the names of their identifiers to only ([UNICODE]) letters, underscores, and digits, not including patterns that look like cell references or the words True or False.
[A-Za-z]+[0-9]+ matches patterns such as A1, AA1, i.e cell references which are invalid according to the oasis open source spec.
Excel is actually wrong here and hyperformula is correct I think. However for compatibility reasons this probably should be fixed? Or made a config option even to allow it.
The spec seems silly in this regard though because Product1 is never mistaken for a cell reference. The regex is far too generic imo... but 🤷
For me, the regex from the spec looks too inaccurate as well, and it may be amended in the next spec versions.
I guess, this is not the only point where Excel diverges from various specifications. And as a HyperFormula user, I'd prefer to have an option specifying strictness/compatibility mode to be able to use my existing datasheets with as few modifications as possible.
At least, this discrepancy should be accented somewhere in the HF documentation.
Thanks for your points of view. We will investigate the options. Maybe we can apply some form of Postel's law here. Or at least explain the discrepancy better, as @YuriKirilin notes.
I'm more than happy to announce that we just released HyperFormula 2.3.1 where this issue is fixed. We are closing this issue as solved. If there is anything that won't work for you after updating, please leave a comment.
Activity
MartinDawson commentedon Dec 23, 2021
Here is the code
In this commit: e1d91aa
This regex:
/^[A-Za-z]+[0-9]+$/.test(expressionName)It's been taken from here: https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#__RefHeading__1017964_715980110
The spec says this:
[A-Za-z]+[0-9]+matches patterns such as A1, AA1, i.e cell references which are invalid according to the oasis open source spec.Excel is actually wrong here and hyperformula is correct I think. However for compatibility reasons this probably should be fixed? Or made a config option even to allow it.
The spec seems silly in this regard though because
Product1is never mistaken for a cell reference. The regex is far too generic imo... but 🤷YuriKirilin commentedon Dec 24, 2021
For me, the regex from the spec looks too inaccurate as well, and it may be amended in the next spec versions.
I guess, this is not the only point where Excel diverges from various specifications. And as a HyperFormula user, I'd prefer to have an option specifying strictness/compatibility mode to be able to use my existing datasheets with as few modifications as possible.
At least, this discrepancy should be accented somewhere in the HF documentation.
warpech commentedon Feb 10, 2022
Thanks for your points of view. We will investigate the options. Maybe we can apply some form of Postel's law here. Or at least explain the discrepancy better, as @YuriKirilin notes.
sequba commentedon Jan 4, 2023
This bug is closely related to #1058. Both issues will be addressed in pull request #1130
sequba commentedon Mar 3, 2023
@YuriKirilin,
I'm more than happy to announce that we just released HyperFormula 2.3.1 where this issue is fixed. We are closing this issue as solved. If there is anything that won't work for you after updating, please leave a comment.