Defined Names

A defined name assigns a custom name to a cell, a range, or a formula. Formulas can then refer to that name instead of the raw address, which makes them easier to read and easier to maintain.

  • Formulas read closer to what they mean. Amount expresses the intent more clearly than A1 + A2 + A3.
  • Several cells or a complex range can be represented by a single name. Define SalesData for A1:A10 and use SalesData in formulas.
  • A data area is maintained in one place. When the range changes, update the reference of the name instead of every formula that uses it.

Usage

The Name Manager entry is next to the name box in the upper left corner of the sheet. Clicking it displays every defined name and opens the Name Manager, where you can view, edit, and delete defined names.

In a formula, enter the name directly. If a range is named TotalSales, =TotalSales references that range.

Notes

  • A defined name must be unique within the same worksheet, and it cannot conflict with another name or a built-in function.
  • A name cannot begin with a number, and it cannot contain spaces or special characters such as !, @, or #. If an entered name violates these rules, the system reports an error.
  • To change a name, reopen the "Define Name" edit panel, select the name, edit it, and click "OK".
  • To delete a name, select it in the "Define Name" edit panel and click "Delete". Formulas that referenced the name become invalid.
  • Names can be shared across different worksheets in the same workbook, but the uniqueness rule still applies: defining the same name on different worksheets can make references ambiguous.
  • Use meaningful names and avoid very short or vague ones, so that other people can understand and maintain the sheet.
  • If using a defined name causes problems, check that the name is correct, that the reference range is accurate, and that no other name conflicts with it.
  • A name can be set at the workbook level or the worksheet level. Workbook-level names are available throughout the workbook, whereas worksheet-level names are available only on the specific worksheet.

Facade API

The complete Facade API type definitions are in the Facade API.

Create defined names

FWorkbook.newDefinedNameBuilder() creates a defined name builder and returns an FDefinedNameBuilder. Chain its methods to produce the ISetDefinedNameMutationParam object used to create the name.

These are some of the member methods on FDefinedNameBuilder:

MethodDescription
buildBuilds the defined name object
setNameSets the defined name
setFormulaSets the formula for the defined name
setRefSets the reference range for the defined name
setCommentSets the comment for the defined name
setScopeToWorksheetSets the defined name to be available for a specific worksheet
setScopeToWorkbookSets the defined name to be available for the entire workbook

FWorkbook.insertDefinedNameBuilder() creates a defined name that is available for the entire workbook.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedNameParam = fWorkbook.newDefinedNameBuilder()  .setName('MyDefinedName')  .setRef('Sheet1!$A$1')  .setComment('A reference to A1 cell in Sheet1')  .build()fWorkbook.insertDefinedNameBuilder(definedNameParam)

FWorkbook.insertDefinedName() is a shortcut for creating a defined name when the name and the reference are already known.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.insertDefinedName('MyDefinedName', 'Sheet1!$A$1')

Other methods:

Get defined names

FWorkbook.getDefinedName() gets one defined name from the workbook and returns an FDefinedName.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())if (definedName) {  definedName.setName('NewDefinedName')}

Other methods:

Modify defined names

FWorkbook.updateDefinedNameBuilder() modifies a defined name in the workbook.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())// Modify the defined nameif (definedName) {  const newDefinedNameParam = definedName.toBuilder()    .setName('NewDefinedName')    .setRef('Sheet1!$A$2')    .build()  fWorkbook.updateDefinedNameBuilder(newDefinedNameParam)}

You can also change the configuration directly on the returned FDefinedName instance.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())// Modify the defined nameif (definedName) {  definedName.setName('NewDefinedName')  definedName.setRef('Sheet1!$A$2')}

Delete defined names

FWorkbook.deleteDefinedName() deletes a defined name in the workbook.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.deleteDefinedName('MyDefinedName')

You can also delete the name through the returned FDefinedName instance.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())// Delete the defined nameif (definedName) {  definedName.delete()}

How is this guide?

© 2026 DreamNum Co., Ltd.