Repository navigation
Add TEXTBEFORE, TEXTAFTER and TEXTSPLIT functions (HF-465, HF-466, HF-467) - #1792
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | e406905 | Commit Preview URL Branch Preview URL |
Nov 27 2026, 06:13 AM |
Performance comparison of head (e406905) vs base (49867c0) |
ee4be12 to
08ca084
Compare
4a01775 to
a2b1098
Compare
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A number literal with a sign is parsed as a unary operator, so the result size of =TEXTSPLIT(-12.5, ".") was not predicted and the formula returned #VALUE!. The two remaining differences from Excel (#N/A instead of #CALC!, literal arguments needed for sizing) are documented. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y table Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rals and match an empty delimiter in a list at once Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cdceafe to
c182b27
Compare
…guage packs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
…c parameter names Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ting # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The #CALC! difference becomes a row of the built-in functions table, next to SEQUENCE, and the sizing rule for spilled results moves to the known limitations, beside the one for other array-producing functions. The notes under the table explain rows of the table only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LIT in svSE TEXTAFTER is TEKST.PO in Polish and TEXTODESPUES in Spanish, and TEXTSPLIT is DELATEXT in Swedish: Microsoft's alphabetical function list and the function's own page agree on each name in its title and syntax, and Excel with a Polish interface returns TEKST.PO in formulasLocal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
…does TEXTBEFORE and TEXTAFTER return an empty text when if_not_found is a reference to an empty cell; an empty argument slot still counts as omitted. TEXTSPLIT pads with an empty value when pad_with is empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md # hyperformula/src/interpreter/plugin/TextPlugin.ts # hyperformula/src/license/functionCapabilities.ts
…re sources disagree An empty argument slot still means that TEXTSPLIT does not split along that axis, but a reference to an empty cell is now the empty text, which is #VALUE! as in Excel, instead of the whole text. The daDK names of TEXTAFTER and TEXTBEFORE and the ruRU name of TEXTBEFORE go back to English: Microsoft's alphabetical list and the function pages disagree, so they wait for product verification. The CHANGELOG entry says what the three functions do and that TEXTSPLIT spills only for constant text and delimiters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r it to spill The result is sized from the text, both delimiters, ignore_empty and match_mode, so every argument but pad_with has to be a constant; the entry said only the text and the delimiters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fits A given instance_num larger in absolute value than the length of the text minus the length of the shortest delimiter, plus 1, is #VALUE!, so an empty text or a delimiter longer than the text with an explicit instance_num is #VALUE!, as in Excel. With instance_num omitted, the same case counts as not found, so it gives if_not_found or #N/A, and match_end no longer returns the whole text for a delimiter longer than the text. An empty delimiter still matches at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…el does TEXTBEFORE and TEXTAFTER round instance_num down, so -0.5 is -1 and -1.5 is -2, and truncate match_mode and match_end before checking that they are 0 or 1, so 0.5 and -0.5 count as 0. TEXTSPLIT truncates match_mode the same way, also when it sizes a literal result. The known limitations say that a range or array of several cells as TEXTSPLIT's text, ignore_empty or match_mode is #VALUE!, also inside another function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 96f541c. Configure here.
The result is sized from every argument but pad_with, as the CHANGELOG entry and the known limitations say. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md # docs/guide/known-limitations.md
# Conflicts: # CHANGELOG.md # hyperformula/src/license/functionCapabilities.ts
Tobiadefami
left a comment
There was a problem hiding this comment.
One blocking: the backward search with two delimiters ending at the same place. The rest is your call: numbers converted with 17 digits, two small doc nits, and a few test gaps on hyperformula-tests#84. I'll approve once the blocking one is fixed.
hyperformula/src/interpreter/plugin/TextPlugin.ts:1148
suggestion: A number passed as text or as a delimiter is turned into text with JavaScript's conversion, which keeps up to 17 digits, while Excel writes 15 significant digits. Measured in Microsoft Excel Online:
['=TEXTAFTER(0.1+0.2,"3")'], // Excel "", here "0000000000000004"
['=TEXTBEFORE(0.1+0.2,"4",,,,"nf")'], // Excel "nf", here "0.3000000000000000"
['=LEN(TEXTAFTER(1/3,"3"))'], // Excel 14, here 15coerceScalarToText, a few lines below, already writes 15 digits; CONCAT uses it, which is why =CONCAT(0.1+0.2) gives 0.3. Could the three new functions convert numbers with it too, for text and the delimiters?
# Conflicts: # CHANGELOG.md # docs/guide/known-limitations.md # docs/guide/list-of-differences.md # hyperformula/src/license/functionCapabilities.ts
…bers to 15 digits
With a negative instance_num, each occurrence is now the one that starts last among those starting no later
than the start of the previous occurrence minus its length, with the longest delimiter winning at one position,
so =TEXTBEFORE("abcbc",{"bc","c"},-2) returns "abc", as in Excel. A number passed as the text or a delimiter of
TEXTBEFORE, TEXTAFTER or TEXTSPLIT is written to 15 significant digits, as in CONCAT, and TEXTSPLIT sizes a number
literal the same way. The match_end description now covers a negative instance_num, and the differences page
lists pad_with given as an array.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Medium risk: Adds three new built-in text functions with entries in all 17 language packs, the function catalogue and the metadata API; failures would be confined to the new functions' behaviour and localized-name lookups rather than existing formulas.
Full review: no issues found.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
|
On the number conversion: done in 23df7e7, so a number passed as |
…ting # Conflicts: # CHANGELOG.md # docs/guide/known-limitations.md # hyperformula/src/license/functionCapabilities.ts
There was a problem hiding this comment.
Note
Medium risk: Adds localized function names to runtime i18n dictionaries used for formula parsing in every locale, plus docs; a wrong or colliding name makes formulas unparseable in that language, but the blast radius is bounded to the affected locales/functions.
Incremental review: 2 potential issue(s).
hyperformula/src/i18n/languages/ptPT.ts:444
ptPT PERCENTRANK.EXC name has a typo (ORDEM.PORCENTUAL.EXC)
Medium severity
The new entry maps PERCENTRANK.EXC to 'ORDEM.PORCENTUAL.EXC', while PERCENTRANK and PERCENTRANK.INC on the adjacent lines use 'ORDEM.PERCENTUAL'. 'PORCENTUAL' is not the Portuguese spelling, so pt-PT users typing Excel's actual name ORDEM.PERCENTUAL.EXC get #NAME? and the sibling functions become unreachable under their documented localized names. This looks like a hand-edit typo introduced by this change.
Suggestion: Change the value to 'ORDEM.PERCENTUAL.EXC'.
hyperformula/src/i18n/languages/nlNL.ts:439
nlNL PERCENTRANK family uses three inconsistent spellings
Low severity
The three sibling entries added here are 'PERCENT.RANG' (PERCENTRANK), 'PROCENTRANG.INC' and 'PROCENTRANG.EXC'. Excel's nl-NL names for the three functions share one prefix (PERCENTRANG / PERCENTRANG.INC / PERCENTRANG.EXC), so at least one of these localized names will not match what Dutch-locale users type, yielding #NAME?. Even without external verification, the three added siblings disagreeing on both the dot placement and PERCENT/PROCENT within the same addition signals a copy error.
Suggestion: Verify against Microsoft's nl-NL function list and use one consistent prefix for all three (expected: PERCENTRANG, PERCENTRANG.INC, PERCENTRANG.EXC).
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
…ting # Conflicts: # CHANGELOG.md
…ting # Conflicts: # CHANGELOG.md
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1792 +/- ##
=========================================
Coverage 97.75% 97.76%
=========================================
Files 212 212
Lines 18940 19159 +219
Branches 4464 4540 +76
=========================================
+ Hits 18515 18730 +215
- Misses 425 429 +4
🚀 New features to boost your workflow:
|

Context
The PR adds the text functions
TEXTBEFORE,TEXTAFTERandTEXTSPLIT.#NAME?.TextPlugin.ts: the three functions.TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])returns the text before the nthdelimiter;TEXTAFTERreturns the text after it. A negativeinstance_numcounts from the end,match_mode1 ignores case,match_end1 treats the end of the text as a delimiter, andif_not_foundreplaces#N/A.instance_numis rounded down andmatch_modeandmatch_endare truncated, as Excel does. An empty delimiter matches at once; otherwise a giveninstance_numpast the last place where the shortest delimiter fits in the text is#VALUE!, and wheninstance_numis omitted, the delimiter is not found. So=TEXTBEFORE("abc","abcd",1)is#VALUE!and=TEXTBEFORE("abc","abcd")is#N/A.TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])splits text into a two-dimensional array that spills;match_modeis truncated. An empty delimiter slot, as in=TEXTSPLIT("a,b",,";"), leaves that axis unsplit; a reference to an empty cell is the empty text, which is#VALUE!.categories/text.ts,functionCapabilities.tsand 17 language files: catalogue entries, license capability entries and names. A localized name is used where Microsoft's alphabetical list and the function's page agree on it in the title and the syntax. Otherwise, and foridID, the English name is kept, as is any name that would duplicate another function (PolishTEXTSPLIT, below).docs/guide/list-of-differences.md: twoTEXTSPLITrows,#N/Awhere Excel returns#CALC!, and an array aspad_with, which Excel rejects with#VALUE!.docs/guide/known-limitations.md: whenTEXTSPLITcan size its result, and that a range of several cells as its text,ignore_emptyormatch_modeis#VALUE!.CHANGELOG.md: oneAddedentry.How did you test your changes?
Paired tests:
feat/hf-text-splittinginhyperformula-tests(handsontable/hyperformula-tests#84).npx jeston the 3 new specs: 366 passed at this head.TEXTSPLITtoo wide for the sheet (1), theinstance_numbound (30), roundinginstance_numdown (4) and truncating the two modes (12).npx jestwith the paired tests: 588 suites passed; 16958 tests passed, 3 skipped.npx tsc --noEmitpasses;npx eslinton the changed.tsfiles: 0 errors. The fullnpm run lintruns in the CIlintjob.differential.json 6564 formulas: 0 blocking againstdevelop. Against the previous head, 96a95aa, 8 blocking, all an empty cell as aTEXTSPLITdelimiter that is now#VALUE!, as requested in review and as Excel returns.AI assistance
Claude Code wrote the three implementations, the catalogue and license entries, the language-pack names, the docs rows, the CHANGELOG entry, the paired tests and this description. Every commit on both branches, other than merges, carries its co-author line.
Compatibility with Excel and Google Sheets
Measured in Excel Online on an account with the Polish locale; Google Sheets was not checked. The edge-case set puts 39 kinds of input (empty cell,
"", omitted, booleans, numeric text, errors, signs, fractions,1e21,1e-7, ranges, arrays, a whole column, another sheet, names) into the arguments of the three functions one at a time, and pairsNA()with them for error precedence. With the review's cases, that is 1376 formulas: 1138 identical, 18 refused by Excel (1e308), 220 different. Another 79 formulas on empty-cell delimiters, delimiters longer than the text,match_endand theinstance_numbound are all identical.=COLUMNS(TEXTSPLIT("a,b",Z1)),Z1empty#VALUE!#VALUE!=COLUMNS(TEXTSPLIT("a,b",,";"))=TEXTBEFORE("a,b",Z1),Z1empty=TEXTBEFORE("abc","abcd")#N/A#N/A=TEXTBEFORE("abc","abcd",1)#VALUE!#VALUE!=TEXTBEFORE("a,b,c",",",-0.5,0,0,"nf")a,ba,b=TEXTAFTER("a,b,c",",",1,0.5,0,"nf")b,cb,c=TEXTSPLIT(",,",",",,TRUE())#CALC!#N/AThe 220 differences, by cause:
useArrayArithmeticthe result matches=TEXTBEFORE(A1:A2,",",1,0,0,"nf")nf#VALUE!TEXTSPLIT's text,ignore_emptyormatch_mode(known limitations)=TEXTSPLIT(A1:A2,",",";",FALSE(),0,"-")#VALUE!TEXTSPLITargument, so the result is sized as one cell (known limitations)=TEXTSPLIT("a,b;c,d",A1:A1,";",FALSE(),0,"-")a,b#VALUE!0.5as0,5andTRUEasPRAWDA=TEXTBEFORE(0.5,",",1,0,0,"nf")0nf=TEXTBEFORE(myRange,",",1,0,0,"nf")nf#VALUE!A:A=TEXTBEFORE(A:A,",",1,0,0,"nf")#SPILL!#VALUE!""asTEXTSPLIT'signore_emptyis not an error before a laterNA()=TEXTSPLIT("a,b;c,d",",",";","",NA(),"-")#VALUE!#N/ATEXTSPLIT'spad_with=TEXTSPLIT("a,b;c,d",",",";",FALSE(),0,{1})#VALUE!aThe named range, whole column and
""rows come from how the engine reads arguments, so they are not changed here. The deliberate differences are in the docs:#N/Awhere Excel returns#CALC!and an array aspad_with(list of differences), and whenTEXTSPLITcan size its result (known limitations).Public API changes
None. Three new built-in functions.
Out of scope and follow-ups
TEXTSPLITkeeps the English name. Excel with the Polish locale returnsPODZIEL.TEKSTfor it, andTEKST.PRZEDandTEKST.POfor the other two (formulasLocal), butPODZIEL.TEKSTis already the Polish name ofSPLITin this pack, while Google Sheets' Polish list calls that functionSPLIT. Moving the name toTEXTSPLITrenamesSPLIT, a breaking change, so it is not done here.TEXTBEFOREandTEXTAFTERand RussianTEXTBEFOREkeep the English names: Microsoft's alphabetical list givesTEKSTFØR,TEKSTEFTERandТЕКСТДО, but the function pages showTEKST.FØR,TEKST.EFTERandTEXTBEFORE. They stay English until a Danish and a Russian Excel confirm a name.TEXTSPLIT'spad_withis#VALUE!in Excel even when nothing is padded; HyperFormula uses its value. It is left as it is.SEQUENCEincluded (=SEQUENCE(1+1)is#VALUE!), so it is not changed here.Types of changes
Related issues
TEXTBEFORE), HF-466 (TEXTAFTER), HF-467 (TEXTSPLIT)Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code
Note
Low Risk
New non-breaking formula features in the text plugin with documented Excel differences; no changes to auth, data handling, or public API surface beyond new function names.
Overview
Adds Excel-style TEXTBEFORE, TEXTAFTER, and TEXTSPLIT built-ins in
TextPlugin, including delimiter occurrence logic (instance from start/end, case and end-of-text modes, customif_not_found) and TEXTSPLIT row/column splitting with padding and parse-time array sizing when arguments are literals.Registers the functions in the metadata catalogue, license capabilities, and 17 language packs. CHANGELOG and user docs note TEXTSPLIT spill limits (literal-only sizing, documented in known limitations) and one Excel difference (
#N/Avs#CALC!for some empty-split cases).Reviewed by Cursor Bugbot for commit 95e26ab. Bugbot is set up for automated code reviews on this repo. Configure here.