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.
delete(): voidExamples
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.
getComment(): string | undefinedReturns
The comment of the defined name.
Examples
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.
getFormulaOrRefString(): stringReturns
The formula or reference string of the defined name.
Examples
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.
getLocalSheetId(): string | undefinedReturns
The local sheet id of the defined name.
Examples
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.
getName(): stringReturns
The name of the defined name.
Examples
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.
isWorkbookScope(): booleanReturns
True if the defined name is in the workbook scope, false otherwise.
Examples
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.
setComment(comment: string): voidParameters
comment— Required. The comment of the defined name.
Examples
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.
setFormula(formula: string): voidParameters
formula— Required. The formula without the leading=; this method prepends it.
Examples
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.
setHidden(hidden: boolean): voidParameters
hidden— Required. The hidden status of the defined name.
Examples
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.
setName(name: string): voidParameters
name— Required. The name of the defined name.
Examples
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.
setRef(refString: string): voidParameters
refString— Required. The reference of the defined name.
Examples
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.
setRefByRange(row: number, column: number, numRows: number, numColumns: number): voidParameters
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
const fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedNames()[0]definedName?.setRefByRange(1, 3, 2, 5) // D2:H3Package: @univerjs/sheets · Type definitions
FDefinedName.setScopeToWorkbook
Sets the scope of the defined name to the workbook.
setScopeToWorkbook(): voidExamples
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.
setScopeToWorksheet(worksheet: FWorksheet): voidParameters
worksheet— Required. The worksheet to set the scope to.
Examples
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.
toBuilder(): FDefinedNameBuilderReturns
The defined name builder.
Examples
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?