Skip to content

Work with profiles and locales ​

Use this page when a workbook has to behave like Excel in a given language and platform: formulas typed in German, numbers shown with a decimal comma, or text sorted the way Japanese Excel sorts it. Locale profiles explains what a profile decides, and Text collation covers comparison and sorting in depth. The calls are under Profiles and formula text in the WASM API and Profiles, locale and text in the Python API.

Pick a profile ​

A profile id names an Excel build and locale, such as mac-365-de_DE or win-365-ja_JP; listProfileIds() lists all 28. Workbook.createForProfile(id) creates a workbook under a profile, wb.setProfileId(id) switches an open one, and a workbook created any other way uses win-365-en_US. The profile is runtime state: it is not saved in the file, so set it again after Workbook.load.

js
import createFormulon from '@libraz/formulon'

const formulon = await createFormulon()
console.log(formulon.listProfileIds().length) // 28

const wb = formulon.Workbook.createForProfile('mac-365-de_DE')
try {
  console.log(wb.getProfileId()) // mac-365-de_DE

  const back = formulon.Workbook.load(wb.save())
  try {
    console.log(back.getProfileId()) // win-365-en_US
    back.setProfileId('mac-365-de_DE')
    console.log(back.getProfileId()) // mac-365-de_DE
  } finally {
    back.dispose()
  }
} finally {
  wb.dispose()
}
python
import formulon
from formulon import Workbook

print(len(formulon.list_profile_ids()))  # 28

with Workbook.create_for_profile("mac-365-de_DE") as wb:
    print(wb.get_profile_id())  # mac-365-de_DE
    wb.save("profile.xlsx")

with Workbook.load("profile.xlsx") as back:
    print(back.get_profile_id())  # win-365-en_US
    back.set_profile_id("mac-365-de_DE")
    print(back.get_profile_id())  # mac-365-de_DE
bash
formulon profiles
formulon eval --profile mac-365-de_DE '=TEXT(1234.5,"#.##0,00")'

The profile decides locale-dependent results: display text, the decimal and list separators of formula text, function and error names, date recognition from text, collation, and pivot captions. A format code inside a formula, such as the second argument of TEXT, is read in the profile's own notation, so under de_DE the group separator is . and the decimal separator ,.

Translate formulas and function names ​

Formula text stored in a workbook is always the canonical English form, the one setFormula takes and getFormula returns. localizeFormula(formula, profileId) turns it into the form a user of that locale types and sees: function names, list and array separators, decimal points, booleans and error names change, strings do not, and sheet names are requoted by the locale's display rule. An r1c1 option writes the references in the locale's R1C1 spelling (R1C1 references). canonicalizeFormula reverses it, so text a user typed can be passed on to setFormula. localizeFunctionName and canonicalizeFunctionName map a single name.

js
import createFormulon from '@libraz/formulon'

const formulon = await createFormulon()
const profile = 'mac-365-de_DE'

console.log(formulon.localizeFormula('=SUM(A1:A3,1.5)&TRUE', profile)) // =SUMME(A1:A3;1,5)&WAHR
console.log(formulon.localizeFunctionName('VLOOKUP', profile)) // SVERWEIS
console.log(formulon.canonicalizeFunctionName('SVERWEIS', profile)) // VLOOKUP

const wb = formulon.Workbook.createForProfile(profile)
try {
  const ws = wb.sheet(0)
  const typed = '=SUMME(1;2,5)'
  ws.setFormula('A1', formulon.canonicalizeFormula(typed, profile))
  console.log(ws.getFormula('A1'), ws.getValue('A1')) // =SUM(1,2.5) 3.5
  console.log(formulon.localizeFormula(ws.getFormula('A1'), profile)) // =SUMME(1;2,5)
} finally {
  wb.dispose()
}
python
import formulon
from formulon import Workbook

profile = "mac-365-de_DE"

print(formulon.localize_formula("=SUM(A1:A3,1.5)&TRUE", profile))  # =SUMME(A1:A3;1,5)&WAHR
print(formulon.localize_function_name("VLOOKUP", profile))  # SVERWEIS
print(formulon.canonicalize_function_name("SVERWEIS", profile))  # VLOOKUP

with Workbook.create_for_profile(profile) as wb:
    ws = wb[0]
    typed = "=SUMME(1;2,5)"
    ws.set_formula("A1", formulon.canonicalize_formula(typed, profile))
    print(ws.get_formula("A1"), ws["A1"])  # =SUM(1,2.5) 3.5
    print(formulon.localize_formula(ws.get_formula("A1"), profile))  # =SUMME(1;2,5)
bash
formulon eval --profile mac-365-de_DE --local '=SUMME(1;2,5)'

Switch the locale to see one stored formula shown in each language.

Switch locales at runtime

Keep one workbook while trying the built-in seven-language selector and a host-owned update({ locale }) control. The UI, calculation profile, formula display and values move together.

Powered by the real Formulon engine (WASM) — it runs entirely in your browser, nothing is uploaded.

setFormula does not accept localized text: =SUMME(1;2) fails to parse because ; is not the canonical separator. Run the user's text through canonicalizeFormula first. A formula that does not parse in the given locale throws FormulonError (Python FormulaSyntaxError) with the error position.

Read the locale's conventions ​

getLocaleFacts(profileId) returns what a host needs to build an editor or a number input for a locale: the decimal, group and list separators, the array separators, the names of TRUE and FALSE, the localized error names, the date order and the currency symbol. measured says whether the facts come from a measurement of Excel or are estimated.

js
import createFormulon from '@libraz/formulon'

const formulon = await createFormulon()
const facts = formulon.getLocaleFacts('mac-365-de_DE')

console.log(facts.decimalSeparator, facts.groupSeparator, facts.listSeparator) // , . ;
console.log(facts.trueName, facts.falseName) // WAHR FALSCH
console.log(facts.errorNames.find((e) => e.canonical === '#VALUE!').localized) // #WERT!
console.log(facts.currencySymbol, facts.measured) // € true
python
import formulon

facts = formulon.get_locale_facts("mac-365-de_DE")

print(facts.decimal_separator, facts.group_separator, facts.list_separator)  # , . ;
print(facts.true_name, facts.false_name)  # WAHR FALSCH
print(next(e.localized for e in facts.error_names if e.canonical == "#VALUE!"))  # #WERT!
print(facts.currency_symbol, facts.measured)  # € True

Show values as that locale displays them ​

getDisplayText(cell) renders a cell the way Excel shows it under the workbook's profile: a number format's separators, a date's default format, and an error's localized name all follow the profile. The stored value does not change; getValue still returns the number or the canonical error. wb.formatValue(value, code) renders any value under a format code with the same rules. A cell's number format and the code given to formatValue are written in the canonical notation (#,##0.00); only the output follows the locale.

js
import createFormulon from '@libraz/formulon'

const formulon = await createFormulon()
const wb = formulon.Workbook.createForProfile('mac-365-de_DE')
try {
  const ws = wb.sheet(0)
  ws.setValue('A1', 1234.5)
  ws.updateCellFormat('A1', { numberFormat: '#,##0.00' })
  ws.setFormula('A2', '=1+"x"')
  ws.setValue('A3', new Date(2026, 10, 7))

  console.log(ws.getDisplayText('A1').text) // 1.234,50
  console.log(ws.getDisplayText('A2').text, String(ws.getValue('A2'))) // #WERT! #VALUE!
  console.log(ws.getDisplayText('A3').text) // 07.11.26
  console.log(wb.formatValue(0.25, '0.0%').text) // 25,0%

  wb.setProfileId('win-365-en_US')
  console.log(ws.getDisplayText('A1').text) // 1,234.50
} finally {
  wb.dispose()
}
python
from datetime import date

from formulon import Workbook

with Workbook.create_for_profile("mac-365-de_DE") as wb:
    ws = wb[0]
    ws["A1"] = 1234.5
    ws.update_cell_format("A1", number_format="#,##0.00")
    ws.set_formula("A2", '=1+"x"')
    ws["A3"] = date(2026, 11, 7)

    print(ws.get_display_text("A1").text)  # 1.234,50
    print(ws.get_display_text("A2").text, ws["A2"])  # #WERT! #VALUE!
    print(ws.get_display_text("A3").text)  # 07.11.26
    print(wb.format_value(0.25, "0.0%").text)  # 25,0%

    wb.set_profile_id("win-365-en_US")
    print(ws.get_display_text("A1").text)  # 1,234.50

Compare and sort text the way the locale does ​

Text comparison, sorting, UNIQUE, lookups and filters follow the profile's collation, which differs between locales and between the Mac and Windows builds. compareText(a, b, strength, profileId) returns -1, 0 or 1 for a host that needs the same ordering outside a formula, and getCollationClasses(values, strength, profileId) groups values the way UNIQUE and SORT do. The strength (CollationStrength) is the depth of comparison a function uses: Compare for = and criteria functions such as COUNTIF, Dynamic for SORT, UNIQUE and XLOOKUP, and ClassicExact for an exact MATCH or VLOOKUP.

js
import createFormulon, { CollationStrength } from '@libraz/formulon'

const formulon = await createFormulon()
console.log(formulon.compareText('ア', 'あ', CollationStrength.Dynamic, 'mac-365-ja_JP')) // 0
console.log(formulon.compareText('ア', 'あ', CollationStrength.Dynamic, 'win-365-ja_JP')) // -1

function distinctCount(profile) {
  const wb = formulon.Workbook.createForProfile(profile)
  try {
    const ws = wb.sheet(0)
    ws.setValues('A1', [['あ'], ['ア'], ['ア'], ['A']])
    ws.setFormula('B1', '=ROWS(UNIQUE(A1:A4))')
    const values = ws.getTypedValues('A1:A4').map((row) => row[0])
    const classes = formulon.getCollationClasses(values, CollationStrength.Dynamic, profile)
    return `${ws.getValue('B1')} ${classes.classCount}`
  } finally {
    wb.dispose()
  }
}
console.log(distinctCount('mac-365-ja_JP')) // 2 2
console.log(distinctCount('win-365-ja_JP')) // 3 3
python
import formulon
from formulon import CollationStrength, Workbook

print(formulon.compare_text("ア", "あ", CollationStrength.DYNAMIC, "mac-365-ja_JP"))  # 0
print(formulon.compare_text("ア", "あ", CollationStrength.DYNAMIC, "win-365-ja_JP"))  # -1



def distinct_count(profile):
    with Workbook.create_for_profile(profile) as wb:
        ws = wb[0]
        ws.set_values("A1", [["あ"], ["ア"], ["ア"], ["A"]])
        ws.set_formula("B1", "=ROWS(UNIQUE(A1:A4))")
        values = [row[0] for row in ws.get_typed_values("A1:A4")]
        classes = formulon.get_collation_classes(values, CollationStrength.DYNAMIC, profile)
        return ws["B1"], classes.class_count


print(distinct_count("mac-365-ja_JP"))  # (2.0, 2)
print(distinct_count("win-365-ja_JP"))  # (3.0, 3)

Do not substitute Intl.Collator or a Unicode normalization pass for these calls; neither reproduces a named Excel profile.