API Reference

FDefinedName

Access

Access through:

Setup

Register @univerjs/sheets or a preset that includes it. In plugin mode, import @univerjs/sheets/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs/sheets

FDefinedName.delete

Deletes the defined name.

TypeScript
delete(): void

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.delete()

Package: @univerjs/sheets · Type definitions

FDefinedName.getComment

Gets the comment of the defined name.

TypeScript
getComment(): string | undefined

Returns

The comment of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]console.log(definedName?.getComment())

Package: @univerjs/sheets · Type definitions

FDefinedName.getFormulaOrRefString

Gets the formula or reference string of the defined name.

TypeScript
getFormulaOrRefString(): string

Returns

The formula or reference string of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]console.log(definedName?.getFormulaOrRefString())

Package: @univerjs/sheets · Type definitions

FDefinedName.getLocalSheetId

Gets the local sheet id of the defined name.

TypeScript
getLocalSheetId(): string | undefined

Returns

The local sheet id of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]console.log(definedName?.getLocalSheetId())

Package: @univerjs/sheets · Type definitions

FDefinedName.getName

Gets the name of the defined name.

TypeScript
getName(): string

Returns

The name of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]console.log(definedName?.getName())

Package: @univerjs/sheets · Type definitions

FDefinedName.isWorkbookScope

Checks if the defined name is in the workbook scope.

TypeScript
isWorkbookScope(): boolean

Returns

True if the defined name is in the workbook scope, false otherwise.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]console.log(definedName?.isWorkbookScope())

Package: @univerjs/sheets · Type definitions

FDefinedName.setComment

Sets the comment of the defined name.

TypeScript
setComment(comment: string): void

Parameters

  • comment — Required. The comment of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setComment('This is a comment')

Package: @univerjs/sheets · Type definitions

FDefinedName.setFormula

Sets the formula of the defined name.

TypeScript
setFormula(formula: string): void

Parameters

  • formula — Required. The formula without the leading =; this method prepends it.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setFormula('SUM(Sheet1!$A$1)')

Package: @univerjs/sheets · Type definitions

FDefinedName.setHidden

Sets the hidden status of the defined name.

TypeScript
setHidden(hidden: boolean): void

Parameters

  • hidden — Required. The hidden status of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setHidden(true)

Package: @univerjs/sheets · Type definitions

FDefinedName.setName

Sets the name of the defined name.

TypeScript
setName(name: string): void

Parameters

  • name — Required. The name of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setName('NewDefinedName')

Package: @univerjs/sheets · Type definitions

FDefinedName.setRef

Sets the reference of the defined name.

TypeScript
setRef(refString: string): void

Parameters

  • refString — Required. The reference of the defined name.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setRef('Sheet1!$A$1')

Package: @univerjs/sheets · Type definitions

FDefinedName.setRefByRange

Sets the reference of the defined name by range.

TypeScript
setRefByRange(row: number, column: number, numRows: number, numColumns: number): void

Parameters

  • row — Required. The start row of the range.
  • column — Required. The start column of the range.
  • numRows — Required. The number of rows in the range.
  • numColumns — Required. The number of columns in the range.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setRefByRange(1, 3, 2, 5) // D2:H3

Package: @univerjs/sheets · Type definitions

FDefinedName.setScopeToWorkbook

Sets the scope of the defined name to the workbook.

TypeScript
setScopeToWorkbook(): void

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setScopeToWorkbook()

Package: @univerjs/sheets · Type definitions

FDefinedName.setScopeToWorksheet

Sets the scope of the defined name to the worksheet.

TypeScript
setScopeToWorksheet(worksheet: FWorksheet): void

Parameters

  • worksheet — Required. The worksheet to set the scope to.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const sheets = fWorkbook.getSheets()// Get the first defined name and make it available only in the second worksheetconst definedName = fWorkbook.getDefinedNames()[0]definedName?.setScopeToWorksheet(sheets[1])

Types: FWorksheet

Package: @univerjs/sheets · Type definitions

FDefinedName.toBuilder

Converts the defined name to a defined name builder.

TypeScript
toBuilder(): FDefinedNameBuilder

Returns

The defined name builder.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]if (!definedName) throw new Error('definedName is not available')const definedNameParam = definedName  .toBuilder()  .setName('NewDefinedName')  .setFormula('SUM(Sheet1!$A$1)')  .build()fWorkbook.updateDefinedNameBuilder(definedNameParam)

Types: FDefinedNameBuilder

Package: @univerjs/sheets · Type definitions

How is this guide?

© 2026 DreamNum Co., Ltd.