Skip to Content
ClassesFDefinedName

Class: FDefinedName

Extends

  • FBase

Methods

delete()

delete(): void

Deletes the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.delete();

getComment()

getComment(): string

Gets the comment of the defined name.

Returns

string

The comment of the defined name.

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; console.log(definedName.getComment());

getFormulaOrRefString()

getFormulaOrRefString(): string

Gets the reference of the defined name.

Returns

string

The reference of the defined name.

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; console.log(definedName.getFormulaOrRefString());

getLocalSheetId()

getLocalSheetId(): string

Gets the local sheet id of the defined name.

Returns

string

The local sheet id of the defined name.

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; console.log(definedName.getLocalSheetId());

getName()

getName(): string

Gets the name of the defined name.

Returns

string

The name of the defined name.

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; console.log(definedName.getName());

isWorkbookScope()

isWorkbookScope(): boolean

Checks if the defined name is in the workbook scope.

Returns

boolean

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

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; console.log(definedName.isWorkbookScope());

setComment()

setComment(comment): void

Sets the comment of the defined name.

Parameters

ParameterTypeDescription
commentstringThe comment of the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.setComment('This is a comment');

setFormula()

setFormula(formula): void

Sets the formula of the defined name.

Parameters

ParameterTypeDescription
formulastringThe formula of the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedName('MyDefinedName'); definedName.setFormula('SUM(Sheet1!$A$1)');

setHidden()

setHidden(hidden): void

Sets the hidden status of the defined name.

Parameters

ParameterTypeDescription
hiddenbooleanThe hidden status of the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.setHidden(true);

setName()

setName(name): void

Sets the name of the defined name.

Parameters

ParameterTypeDescription
namestringThe name of the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedName('MyDefinedName'); definedName.setName('NewDefinedName');

setRef()

setRef(refString): void

Sets the reference of the defined name.

Parameters

ParameterTypeDescription
refStringstringThe reference of the defined name.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.setRef('Sheet1!$A$1');

setRefByRange()

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

Sets the reference of the defined name by range.

Parameters

ParameterTypeDescription
rownumberThe start row of the range.
columnnumberThe start column of the range.
numRowsnumberThe number of rows in the range.
numColumnsnumberThe number of columns in the range.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.setRefByRange(1, 3, 2, 5);

setScopeToWorkbook()

setScopeToWorkbook(): void

Sets the scope of the defined name to the workbook.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; definedName.setScopeToWorkbook();

setScopeToWorksheet()

setScopeToWorksheet(worksheet): void

Sets the scope of the defined name to the worksheet.

Parameters

ParameterTypeDescription
worksheetFWorksheetThe worksheet to set the scope to.

Returns

void

Example

const workbook = univerAPI.getActiveWorkbook(); const worksheet = workbook.getWorksheets[0]; const definedName = workbook.getDefinedNames[0]; definedName.setScopeToWorksheet(worksheet);

toBuilder()

toBuilder(): FDefinedNameBuilder

Converts the defined name to a defined name builder.

Returns

FDefinedNameBuilder

The defined name builder.

Example

const workbook = univerAPI.getActiveWorkbook(); const definedName = workbook.getDefinedNames[0]; const definedNameBuilder = definedName.toBuilder(); const param definedNameBuilder.setName('NewDefinedName').setFormula('SUM(Sheet1!$A$1)').build(); workbook.updateDefinedNameBuilder(param);