Skip to content

HF-24: add stringifyCurrency config callback for TEXT#1661

Closed
marcin-kordas-hoc wants to merge 7 commits intohandsontable:developfrom
marcin-kordas-hoc:feature/hf-24-stringify-currency
Closed

HF-24: add stringifyCurrency config callback for TEXT#1661
marcin-kordas-hoc wants to merge 7 commits intohandsontable:developfrom
marcin-kordas-hoc:feature/hf-24-stringify-currency

Conversation

@marcin-kordas-hoc
Copy link
Copy Markdown
Collaborator

@marcin-kordas-hoc marcin-kordas-hoc commented Apr 27, 2026

Summary

Adds a stringifyCurrency config option mirroring the existing stringifyDateTime / stringifyDuration callbacks. When set, the TEXT function consults the callback before falling through to the built-in number formatter, so users can plug in locale-aware currency formatting (for example via Intl.NumberFormat or a third-party library) without bringing currency data into the HyperFormula core.

The default implementation returns undefined so existing TEXT behavior is preserved bit-for-bit.

Linked

  • Spec: agents/hyperformula/docs/specs/2026-04-21-hf-24-currency-in-text.md
  • Tech rationale: agents/hyperformula/docs/specs/2026-04-24-hf-24-tech-rationale.md
  • Implementation plan: agents/hyperformula/docs/specs/2026-04-27-hf-24-stringify-currency-plan.md

Tests

Tests added in the matching feature/hf-24-stringify-currency branch of handsontable/hyperformula-tests. Coverage:

  • default callback returns undefined
  • custom callback intercepts currency formats
  • callback opts out (returns undefined) → fall-through to numberFormat
  • date / duration formats are not intercepted by stringifyCurrency
  • six representative Excel format strings handled by the docs Intl.NumberFormat adapter (USD, EUR via LCID, JPY via LCID, PLN via LCID, accounting two-section, fall-through)

Notes

  • PLN format string change: the spec example originally used #,##0.00 "zł" (trailing quoted symbol). HF's formula parser does not accept embedded quotes inside TEXT format strings, so the docs example and the corresponding test were swapped to use [$zł-415] #,##0.00 (LCID-tagged symbol). The adapter still recognizes the trailing-quote pattern for users invoking the callback outside HyperFormula.
  • Pre-existing lint errors (9, all in test/hyperformula-tests/unit/memory-management.spec.ts) are unrelated to this PR — they originate from PR NUMBER type precision is not precise enough #4 of the private repo and should be fixed in a separate ticket.

Test plan

  • CI green on handsontable/hyperformula PR
  • CI green on handsontable/hyperformula-tests PR (matching branch)
  • Manual: build docs locally, render the new "Currency integration" section under Date and time handling, copy-paste the adapter into a fresh sandbox to confirm it runs against Intl.NumberFormat on Node 14+

Note

Medium Risk
Touches the TEXT formatting pipeline by inserting a new callback hook; default behavior is preserved, but a misbehaving callback could change output for any TEXT formatting call.

Overview
Adds a new stringifyCurrency configuration callback (mirroring stringifyDateTime/stringifyDuration) that lets callers intercept TEXT(value, format) and return a currency-formatted string.

format() now consults config.stringifyCurrency(value, formatArg) after date/duration formatting and before the built-in numberFormat fallback; the shipped defaultStringifyCurrency returns undefined to keep existing output unchanged.

Documentation and changelog are updated with a new Currency integration guide section and examples (including an Intl.NumberFormat adapter).

Reviewed by Cursor Bugbot for commit 0246ce0. Bugbot is set up for automated code reviews on this repo. Configure here.


Private tests PR: handsontable/hyperformula-tests#10

@qunabu
Copy link
Copy Markdown

qunabu commented Apr 27, 2026

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@marcin-kordas-hoc
Copy link
Copy Markdown
Collaborator Author

Superseded by #1665.

Same content (same HEAD SHA), but routed from the upstream branch instead of fork. The fork-side PR was hitting a structural CI failure: 3 matrix checks (Test performance, unit-tests, browser-tests) require the DEPLOY_TOKEN secret to clone the private hyperformula-tests repo, and GitHub does not expose org secrets to fork-originated workflow runs. Re-routing to the upstream branch resolves that.

Worktree push routing for future PRs is being fixed locally so this won't repeat.

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.

2 participants