# FDefinedName

> Language fallback: requested `ko-KR`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/ko-KR/reference/facade/defined-name](https://docs.univer.ai/ko-KR/reference/facade/defined-name)

- Agent Markdown: [https://docs.univer.ai/ko-KR/reference/facade/defined-name.md](https://docs.univer.ai/ko-KR/reference/facade/defined-name.md)

- Requested language: `ko-KR`

- Content language: `en-US`

- Documentation version: `1.0.4`

- Source: [facade/defined-name.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/defined-name.mdx)

---

## Access

Access through:

* [`FWorkbook.getDefinedName()`](https://docs.univer.ai/ko-KR/reference/facade/workbook.md#getdefinedname)
* [`FWorkbook.getDefinedNames()`](https://docs.univer.ai/ko-KR/reference/facade/workbook.md#getdefinednames)
* [`FWorksheet.getDefinedNames()`](https://docs.univer.ai/ko-KR/reference/facade/worksheet.md#getdefinednames)

## Setup

Register [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) or a preset that includes it. In plugin mode, import `@univerjs/sheets/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/ko-KR/guides/sheets/getting-started/facade.md).

## `@univerjs/sheets`

### `FDefinedName.delete`

Deletes the defined name.

```typescript
delete(): void
```

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.getComment`

Gets the comment of the defined name.

```typescript
getComment(): string | undefined
```

**Returns**

The comment of the defined name.

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.getName`

Gets the name of the defined name.

```typescript
getName(): string
```

**Returns**

The name of the defined name.

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.setComment`

Sets the comment of the defined name.

```typescript
setComment(comment: string): void
```

**Parameters**

* `comment` — Required. The comment of the defined name.

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.setName`

Sets the name of the defined name.

```typescript
setName(name: string): void
```

**Parameters**

* `name` — Required. The name of the defined name.

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.setRef`

Sets the reference of the defined name.

```typescript
setRef(refString: string): void
```

**Parameters**

* `refString` — Required. The reference of the defined name.

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.setScopeToWorkbook`

Sets the scope of the defined name to the workbook.

```typescript
setScopeToWorkbook(): void
```

**Examples**

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

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `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**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const sheets = fWorkbook.getSheets()

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

**Types:** [`FWorksheet`](https://docs.univer.ai/ko-KR/reference/facade/worksheet.md)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)

### `FDefinedName.toBuilder`

Converts the defined name to a defined name builder.

```typescript
toBuilder(): FDefinedNameBuilder
```

**Returns**

The defined name builder.

**Examples**

```ts
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`](https://docs.univer.ai/ko-KR/reference/facade/defined-name-builder.md)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/f-defined-name.d.ts)
