Skip to content

Add TEXTJOIN function - #1625

Closed
marcin-kordas-hoc wants to merge 5 commits into
handsontable:developfrom
marcin-kordas-hoc:feature/TEXTJOIN_w_docs
Closed

marcin-kordas-hoc wants to merge 5 commits into
handsontable:developfrom
marcin-kordas-hoc:feature/TEXTJOIN_w_docs

Conversation

@marcin-kordas-hoc

@marcin-kordas-hoc marcin-kordas-hoc commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Implements TEXTJOIN(delimiter, ignore_empty, text1, [text2, …]) in TextPlugin
  • Supports scalar and array/range delimiters (with cycling when delimiter is a range)
  • Skips empty strings when ignore_empty is TRUE; includes them when FALSE
  • Returns #VALUE! when the result exceeds 32,767 characters (Excel cell limit)
  • Adds ErrorMessage.TextJoinResultTooLong for the length-exceeded error
  • Adds translations for all 17 supported languages
  • Documents the function in docs/guide/built-in-functions.md

Test plan

  • 22 unit tests in test/textjoin.spec.ts covering basic usage, ignore_empty behaviour, array/range delimiters with cycling, type coercion, error propagation, and edge cases
  • Smoke tests in test/smoke.spec.ts include TEXTJOIN scenarios
  • All 41 tests pass (npm run test:jest)
  • TypeScript compiles without errors (npm run compile)
  • No lint errors (npm run lint)

Note

Medium Risk
Adds a new core formula function in the interpreter (TEXTJOIN) with range handling, delimiter cycling, and a new #VALUE! error path, which could affect calculation behavior in edge cases. Changes are additive and well-covered by new unit/smoke tests.

Overview
Adds support for the TEXTJOIN(delimiter, ignore_empty, text1, [text2, …]) formula, including scalar or range/array delimiters (cycled between joined parts), optional skipping of empty strings, and propagation of cell errors from delimiter/text inputs.

Introduces a new ErrorMessage.TextJoinResultTooLong and returns #VALUE! when the joined result exceeds 32,767 characters. Updates built-in function documentation, adds TEXTJOIN translations across supported languages, and adds dedicated TEXTJOIN unit tests plus smoke coverage.

Written by Cursor Bugbot for commit cfa61b5. This will update automatically on new commits. Configure here.

sequba and others added 3 commits February 20, 2026 13:18
* Fix package-lock file

* Docs: remove CodeSandbox embedded demos and add links to working exa,ples in Stackblitz (handsontable#1621)
- Remove dead code: redundant CellError check after coerceScalarToString in flattenArgToStrings
- Remove empty no-op afterEach callback from textjoin test suite
@marcin-kordas-hoc marcin-kordas-hoc self-assigned this Feb 26, 2026
@marcin-kordas-hoc marcin-kordas-hoc added the Function Feature or bug in formula function label Feb 26, 2026

@sequba sequba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

Comment thread test/smoke.spec.ts Outdated
Per code review: smoke.spec.ts should stay minimal. All TEXTJOIN tests
are now consolidated in textjoin.spec.ts, covering individual cell
references, single-ref args, and explicit empty-string vs null cell
behaviour for ignore_empty=TRUE/FALSE.
Comment thread test/textjoin.spec.ts
@@ -0,0 +1,309 @@
import {HyperFormula} from '../src'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcin-kordas-hoc Please, move tests to hyperformula-test repository

cursor Bot pushed a commit that referenced this pull request Mar 16, 2026
Address sequba's review feedback on PR #1625:
- Remove test/textjoin.spec.ts (tests belong in hyperformula-test repo)
- Remove TEXTJOIN tests from test/smoke.spec.ts (keep smoke tests basic)
- Fix alphabetical ordering of TEXTJOIN in built-in-functions.md
  (moved from between SUBSTITUTE/T to between TEXT/TRIM)

Co-authored-by: marcin-kordas-hoc <marcin-kordas-hoc@users.noreply.github.com>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

Closing in favor of a new PR from upstream branch (handsontable/hyperformula:feature/TEXTJOIN_w_docs). Review feedback addressed: tests moved to private repo, docs ordering fixed, unsafe cast fixed.

sequba added a commit that referenced this pull request Mar 26, 2026
## Summary

Adds the `TEXTJOIN` function — joins text from multiple strings and/or
ranges with a configurable delimiter.

Replaces #1625 (was opened from fork, now from upstream branch
directly).

### Features
- Scalar and array/range delimiter support with cycling behavior
- `ignore_empty` parameter to skip empty strings
- Type coercion (numbers, booleans → strings)
- Error propagation from both delimiter and text arguments
- 32,767 character limit (Excel compatibility)
- i18n translations for all 17 supported languages
- Documentation in `built-in-functions.md`

### Implementation
- New `textjoin` method + `flattenArgToStrings` helper in `TextPlugin`
- `repeatLastArgs: 1` metadata pattern (same as SUMPRODUCT, etc.)
- Defensive `CellError` check on `coerceScalarToString` return value

### Changed files
| File | Change |
|------|--------|
| `src/interpreter/plugin/TextPlugin.ts` | `textjoin()` +
`flattenArgToStrings()` |
| `src/error-message.ts` | `TextJoinResultTooLong` message |
| `src/i18n/languages/*.ts` (17 files) | TEXTJOIN translations |
| `docs/guide/built-in-functions.md` | TEXTJOIN row (alphabetically
between TEXT and TRIM) |

### Review feedback addressed (from #1625)
- Tests moved to private `hyperformula-tests` repo (companion PR
pending)
- Fixed docs alphabetical ordering
- Fixed unsafe `as string` cast in `flattenArgToStrings`

## Test plan

- [x] 35 tests in
`hyperformula-tests/unit/interpreter/function-textjoin.spec.ts`
- [x] Full suite: 480 suites / 5396 tests passed

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Adds a new interpreter function (`TEXTJOIN`) with range flattening and
type coercion, which touches formula evaluation paths and may introduce
edge-case regressions around error propagation and large-string
handling.
> 
> **Overview**
> Adds the new `TEXTJOIN` spreadsheet function, including interpreter
support for joining scalars and ranges with a delimiter (including
delimiter cycling), optional skipping of empty strings, and consistent
error propagation.
> 
> Introduces a new `ErrorMessage.ResultTooLong` and enforces Excel’s
32,767-character output limit (returning `#VALUE!` when exceeded).
> 
> Updates function documentation, the unreleased changelog, and adds
`TEXTJOIN` translations across all supported language packs.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
81426d7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Kuba Sekowski <jakub.sekowski@handsontable.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Function Feature or bug in formula function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants