ExcelScript.CultureInfo interface

Provides information based on current system culture settings. This includes the culture names, number formatting, and other culturally dependent settings.

Remarks

Examples

/**
 * This script sets the value of a cell to a date string for January 2, 2023.
 * It writes the day or month first in the string based on system settings.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first cell in the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Get the date format.
  const cultureInfo : ExcelScript.CultureInfo = workbook.getApplication().getCultureInfo();
  const systemDateTimeFormat : ExcelScript.DatetimeFormatInfo = cultureInfo.getDatetimeFormat();
  const shortDatePattern : string = systemDateTimeFormat.getShortDatePattern();

  // Determine if the date should start with the month or day.
  if (shortDatePattern.startsWith("m")) {
    cell.setValue("1/2/2023");
  } else {
    cell.setValue("2/1/2023");
  }
}

Methods

getDatetimeFormat()

Defines the culturally appropriate format of displaying date and time. This is based on current system culture settings.

getName()

Gets the culture name in the format languagecode2-country/regioncode2 (e.g., "zh-cn" or "en-us"). This is based on current system settings.

getNumberFormat()

Defines the culturally appropriate format of displaying numbers. This is based on current system culture settings.

Method Details

getDatetimeFormat()

Defines the culturally appropriate format of displaying date and time. This is based on current system culture settings.

getDatetimeFormat(): DatetimeFormatInfo;

Returns

getName()

Gets the culture name in the format languagecode2-country/regioncode2 (e.g., "zh-cn" or "en-us"). This is based on current system settings.

getName(): string;

Returns

string

getNumberFormat()

Defines the culturally appropriate format of displaying numbers. This is based on current system culture settings.

getNumberFormat(): NumberFormatInfo;

Returns