Angular
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. 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:
import { Component } from '@angular/core';
import { TXSheetControlComponent } from '@txtextcontrol/tx-sheet-control/angular';
import { type Spreadsheet, type SpreadsheetOptions } from '@txtextcontrol/tx-sheet-control';
({
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 comes from
@txtextcontrol/tx-sheet-control/angularand is listed inimports. Its element in the template istx-sheet-control. The component mounts the editor outside the Angular change-detection zone. [options]binds the options input to a SpreadsheetOptions object: locale isen-US, height is'fill'and fontCatalogURL is the URL of the deployed font catalog.- The
styleattribute gives the element a definite height of 640 pixels. - ready emits the editor, a Spreadsheet, to
onReady. There, workbook, sheets and at return the first worksheet. - range and setValues write the headings
ItemandAmountand two items into A1:B3, and cell and setFormula put the formula=SUM(B2:B3)into B4. - initializationError reports runtime catalog or font loading failures without emitting a usable control.
onErrorwrites the error to the console. SpreadsheetandSpreadsheetOptionsare imported as types from@txtextcontrol/tx-sheet-control.
Deploy the Assets and Set a Height
- The editor installs its bundled stylesheet inside its own Shadow DOM automatically; do not add a global editor stylesheet.
- Copy
dist/fontsanddist/languagesinto your static assets. If the deployed paths differ, configure the asset base and the catalog in the options, with fontBaseURL andfontCatalogURL. - 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, 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 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 | A change of the workbook |
| loading, saving | A file is about to be parsed or an export snapshot captured; you can cancel the operation |
| loaded, saved | A file operation succeeded; saved follows once the output bytes are ready |
| loadProgress, exportProgress | The actual processing phases, with optional byte and page counts |
| fileOperationFailed | 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 and save. Application data retrieval remains the host's responsibility.
Next Steps
- Angular: look up the component, its outputs and the types of
@txtextcontrol/tx-sheet-control/angular. - Events and Cancellation: handle workbook and file-operation events and cancel operations.
- Dashboard Viewer: host a dashboard-focused viewer with
dashboardMode. - Static Assets and Offline Hosting: 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.