# GC.Spread.Sheets.FormulaPanel.FormulaEditor

## Content

# Class: FormulaEditor

[Sheets](../modules/GC.Spread.Sheets).[FormulaPanel](../modules/GC.Spread.Sheets.FormulaPanel).FormulaEditor

## Table of contents

### Constructors

- [constructor](GC.Spread.Sheets.FormulaPanel.FormulaEditor#constructor)

### Properties

- [options](GC.Spread.Sheets.FormulaPanel.FormulaEditor#options)

### Methods

- [attach](GC.Spread.Sheets.FormulaPanel.FormulaEditor#attach)
- [commandManager](GC.Spread.Sheets.FormulaPanel.FormulaEditor#commandmanager)
- [destroy](GC.Spread.Sheets.FormulaPanel.FormulaEditor#destroy)
- [detach](GC.Spread.Sheets.FormulaPanel.FormulaEditor#detach)
- [format](GC.Spread.Sheets.FormulaPanel.FormulaEditor#format)
- [refresh](GC.Spread.Sheets.FormulaPanel.FormulaEditor#refresh)
- [text](GC.Spread.Sheets.FormulaPanel.FormulaEditor#text)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new FormulaEditor**(`host`, `options?`)

Represents a formula editor.

**`example`**
```javascript
window.onload = function(){
     var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
     formulaEditor = new GC.Spread.Sheets.FormulaPanel.FormulaEditor(document.getElementById("fe"));
     formulaEditor.attach(spread);
}
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `host` | `HTMLElement` | The DOM element. |
| `options?` | [`IFormulaEditorOptions`](../interfaces/GC.Spread.Sheets.FormulaPanel.IFormulaEditorOptions) | - |

## Properties

### <a id="options" name="options"></a> options

• **options**: [`IFormulaEditorOptions`](../interfaces/GC.Spread.Sheets.FormulaPanel.IFormulaEditorOptions)

Indicates the options of the formula editor.

**`property`** {number} tabSize - Indicate the number of spaces inserted when the "Tab" key is pressed. Default is 4.

**`property`** {number} formatWidthLimit - Indicates the width limit when formatting, Default is 'auto'. 'auto' means that this follows the width of the dom and will try to avoid the width of a line exceeding the width of the dom.

**`example`**
```javascript
formulaEditor.options.tabSize = 2;
formulaEditor.options.formatWidthLimit = -1;
```

## Methods

### <a id="attach" name="attach"></a> attach

▸ **attach**(`workbook`): `any`

**`description`** attach to a workbook for formula editor.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `workbook` | [`Workbook`](GC.Spread.Sheets.Workbook) | Indicates the workbook which is attached. |

#### Returns

`any`

void

___

### <a id="commandmanager" name="commandmanager"></a> commandManager

▸ **commandManager**(): [`CommandManager`](GC.Spread.Commands.CommandManager)

Gets the command manager.

**`example`**
```javascript
//This example executes a command that performs a specified action.
formulaEditor.commandManager().execute({ cmd: "formatDocument" });
```

#### Returns

[`CommandManager`](GC.Spread.Commands.CommandManager)

The command manager.

___

### <a id="destroy" name="destroy"></a> destroy

▸ **destroy**(): `void`

Destroys current formula editor.

#### Returns

`void`

___

### <a id="detach" name="detach"></a> detach

▸ **detach**(): `void`

**`description`** detach the workbook for formula editor.

#### Returns

`void`

void

___

### <a id="format" name="format"></a> format

▸ **format**(): `void`

format the document(formula string).

#### Returns

`void`

___

### <a id="refresh" name="refresh"></a> refresh

▸ **refresh**(): `void`

refresh the formula editor.

#### Returns

`void`

___

### <a id="text" name="text"></a> text

▸ **text**(`value?`): `string`

Gets or sets the text.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value?` | `string` | The text. |

#### Returns

`string`

If no value is set, returns the text; otherwise, there is no return value.
