useCultureDecimals Boolean (default: false)

If set to true, the Spreadsheet formula parser will obey the decimal separator of the current culture. If set to false (default), the decimal separator in formulas will always be the dot.

This flag has implications on how formulas are entered. When it is set to true, in cultures where the decimal separator is the comma (,), similar to Excel, the following additional changes upon entering a formula will occur:

  • The semicolon will become a function argument separator. For example, =SUM(A1;A2) instead of =SUM(A1,A2).
  • The backslash will become an element separator in an array formula. For example, ={1\2;3\4} instead of ={1,2;3,4}.

This flag only affects the presentation - the way formulas are entered by the end user or displayed on screen. Serialization to JSON or XLSX as well as the public API functions will continue to use the dot as decimal separator and the comma as an argument separator (canonical form). For example, to apply a formula by using the API, even if useCultureDecimals is in effect, you still need to use the canonical form.

sheet.range('B1').formula('SUM(A1, A2, 3.14)');
// or:
sheet.range('B1').input('=SUM(A1, A2, 3.14)');

// prints: SUM(A1, A2, 3.14)
console.log(sheet.range('B1').formula());

To make the API functions obey useCultureDecimals, wrap your code in a call to sheet.withCultureDecimals. Assuming a culture where the comma is used for decimals, compare the previous example with the following one.

sheet.withCultureDecimals(function(){
    sheet.range('B1').formula('SUM(A1; A2; 3,14)');
    // or:
    sheet.range('B1').input('=SUM(A1; A2; 3,14)');

    // prints: SUM(A1; A2; 3,14)
    console.log(sheet.range('B1').formula());
});

// back to canonical form; this prints: SUM(A1, A2, 3.14)
console.log(sheet.range('B1').formula());
In this article
Not finding the help you need? Improve this article