# Angular

> Host the TX Sheet Control spreadsheet editor in Angular with TXSheetControlComponent: bind options, handle ready and error outputs, deploy assets, set a height.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Getting Started > Spreadsheet Editor > Angular
- **1949 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/angular/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/angular/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/angular/llms-full.txt

---

`TXSheetControlComponent` brings the spreadsheet editor into an Angular application. You bind options to it, receive the editor in its `ready` output and work with the workbook through the same API as in JavaScript.

### Install the Package

The Angular integration is included in the editor package `@txtextcontrol/tx-sheet-control`: you import it from `@txtextcontrol/tx-sheet-control/angular`, and there is no separate Angular package. Install the editor package as described in [Install the npm Packages](https://docs.textcontrol.com/tx-sheet-control/installation/npm/#angular). The component requires Angular 22.

### Add the Component

The following standalone component, `AppComponent` with the selector `app-root`, shows the editor and fills its first worksheet as soon as the editor is ready:

```typescript
import { Component } from '@angular/core';
import { TXSheetControlComponent } from '@txtextcontrol/tx-sheet-control/angular';
import { type Spreadsheet, type SpreadsheetOptions } from '@txtextcontrol/tx-sheet-control';

@Component({
    selector: 'app-root', standalone: true,
    imports: [TXSheetControlComponent],
    template: `<tx-sheet-control [options]="options" (ready)="onReady($event)"
        (initializationError)="onError($event)" style="height:640px" />`
})
export class AppComponent {
    options: SpreadsheetOptions = { license: 'YOUR_SIGNED_LICENSE', locale: 'en-US', height: 'fill', fontCatalogURL: '/assets/sheet/fonts/catalog.json' };
    onReady(editor: Spreadsheet): void {
        const sheet = editor.workbook.sheets.at(0);
        sheet.range('A1:B3').setValues([
            ['Item', 'Amount'], ['Hardware', 120], ['Software', 80]
        ]);

        sheet.cell('B4').setFormula('=SUM(B2:B3)');
    }

    onError(error: unknown): void { console.error(error); }
}
```

The code works as follows:

- [TXSheetControlComponent](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/llms-full.txt) comes from `@txtextcontrol/tx-sheet-control/angular` and is listed in `imports`. Its element in the template is `tx-sheet-control`. The component mounts the editor outside the Angular change-detection zone.
- `[options]` binds the [options](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/options-property/llms-full.txt) input to a [SpreadsheetOptions](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/llms-full.txt) object: [locale](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/locale-property/llms-full.txt) is `en-US`, [height](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/height-property/llms-full.txt) is `'fill'` and [fontCatalogURL](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/fontcatalogurl-property/llms-full.txt) is the URL of the deployed font catalog.
- The `style` attribute gives the element a definite height of 640 pixels.
- [ready](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/ready-property/llms-full.txt) emits the editor, a [Spreadsheet](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheet/llms-full.txt), to `onReady`. There, [workbook](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheet/workbook-property/llms-full.txt), [sheets](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/workbook/sheets-property/llms-full.txt) and [at](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/sheetcollection/at-method/llms-full.txt) return the first worksheet.
- [range](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/worksheet/range-method/llms-full.txt) and [setValues](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/range/setvalues-method/llms-full.txt) write the headings `Item` and `Amount` and two items into A1:B3, and [cell](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/worksheet/cell-method/llms-full.txt) and [setFormula](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/cell/setformula-method/llms-full.txt) put the formula `=SUM(B2:B3)` into B4.
- [initializationError](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/initializationerror-property/llms-full.txt) reports runtime catalog or font loading failures without emitting a usable control. `onError` writes the error to the console.
- `Spreadsheet` and `SpreadsheetOptions` are imported as types from `@txtextcontrol/tx-sheet-control`.

### Deploy the Assets and Set a Height

1. The editor installs its bundled stylesheet inside its own Shadow DOM automatically; do not add a global editor stylesheet.
2. Copy `dist/fonts` and `dist/languages` into your static assets. If the deployed paths differ, configure the asset base and the catalog in the options, with [fontBaseURL](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/fontbaseurl-property/llms-full.txt) and `fontCatalogURL`.
3. Give the component and its parent layout a definite height. A height of `100%` needs a parent with a known height.

### How the Component Lifetime Works

The component mounts in the browser and releases its editor on destruction. Server-side page rendering does not create a browser editor.

> Important
>
> **Wait for Ready.** [control](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/control-property/llms-full.txt), the editor of the component, is undefined before mounting. Use `(ready)` instead of assuming that the control exists during construction.

Mutable appearance settings in the options can update in place. The hosting policy [dashboardMode](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/spreadsheetoptions/dashboardmode-property/llms-full.txt) is fixed for the mounted control's lifetime: to change that policy, recreate the component.

### React to Events

The outputs of the component cover ready and error, workbook changes, loading and saving, loaded and saved files, progress and failures:

| Output | Reports |
|---|---|
| `ready`, `initializationError` | The editor is ready, or its initialization failed |
| [workbookChange](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/workbookchange-property/llms-full.txt) | A change of the workbook |
| [loading](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/loading-property/llms-full.txt), [saving](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/saving-property/llms-full.txt) | A file is about to be parsed or an export snapshot captured; you can cancel the operation |
| [loaded](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/loaded-property/llms-full.txt), [saved](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/saved-property/llms-full.txt) | A file operation succeeded; `saved` follows once the output bytes are ready |
| [loadProgress](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/loadprogress-property/llms-full.txt), [exportProgress](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/exportprogress-property/llms-full.txt) | The actual processing phases, with optional byte and page counts |
| [fileOperationFailed](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/fileoperationfailed-property/llms-full.txt) | A failed or canceled operation, which never emits `loaded` or `saved` |

Use the control for the same workbook APIs as JavaScript, and await file operations such as [load](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/load-method/llms-full.txt) and [save](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/txsheetcontrolcomponent/save-method/llms-full.txt). Application data retrieval remains the host's responsibility.

### Next Steps

- [Angular](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/angular/llms-full.txt): look up the component, its outputs and the types of `@txtextcontrol/tx-sheet-control/angular`.
- [Events and Cancellation](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/events/llms-full.txt): handle workbook and file-operation events and cancel operations.
- [Dashboard Viewer](https://docs.textcontrol.com/tx-sheet-control/dashboards/viewer/llms-full.txt): host a dashboard-focused viewer with `dashboardMode`.
- [Static Assets and Offline Hosting](https://docs.textcontrol.com/tx-sheet-control/deployment/static-assets/llms-full.txt): copy the styles and public assets in the application build and point the editor at the catalog.

Before running the example, replace `YOUR_SIGNED_LICENSE` with the contents of your license file, `tx-sheet-control.license`, which the Text Control Account issues for your Trial, Developer or OEM serial number.

---

## Nearby

- **Previous:** [ASP.NET Core](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/aspnet-core/llms-full.txt)
- **Next:** [Blazor](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/blazor/llms-full.txt)
