How to Add a Spreadsheet Editor to an Angular Application
Add a complete spreadsheet editor to an Angular application using TX Sheet Control. This tutorial configures the standalone component and its assets, loads Excel workbooks, changes cells and formulas with TypeScript, and downloads the edited XLSX file.

TX Sheet Control provides a standalone Angular component with a ribbon, formula bar, worksheet tabs, and a typed TypeScript API for editing Excel documents.
Using Angular 22 and TX Sheet Control 2.0.0, we configure the editor, load a sales workbook, update cells and formulas, and download the edited XLSX file. The spreadsheet runs in the browser.
Create a Standalone Angular Application
Install a Node.js version supported by Angular 22, then create a standalone Angular application:
npx @angular/cli@22 new tx-sheet-control-angular --standalone --routing=false --style=css --ssr=false --skip-tests --skip-git --defaults
cd tx-sheet-control-angular
Install TX Sheet Control
Download TX Sheet Control and copy txtextcontrol-tx-sheet-control-2.0.0.tgz from its npm folder into a vendor folder in your Angular project. Install that file with npm:
npm install ./vendor/txtextcontrol-tx-sheet-control-2.0.0.tgz
Import the included TXSheetControlComponent from @txtextcontrol/tx-sheet-control/angular.
Copy Fonts and Language Assets in the Angular Build
In angular.json, replace projects.tx-sheet-control-angular.architect.build.options.assets with the following configuration to copy the public files, fonts, and language resources into the build output:
{
"assets": [
{
"glob": "**/*",
"input": "public"
},
{
"glob": "**/*",
"input": "node_modules/@txtextcontrol/tx-sheet-control/dist/fonts",
"output": "/assets/sheet/fonts"
},
{
"glob": "**/*",
"input": "node_modules/@txtextcontrol/tx-sheet-control/dist/languages",
"output": "/assets/sheet/languages"
}
]
}
The component supplies its editor styles. The font catalog is served at assets/sheet/fonts/catalog.json.
Under build.configurations.production.budgets, set the initial bundle budget to maximumWarning: "7MB" and maximumError: "9MB" for this sample.
Configure the Bootstrap and License
Import @angular/compiler before bootstrapping the application, as required by the 2.0.0 Angular component. Replace src/main.ts with:
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { App } from './app/app';
bootstrapApplication(App, appConfig)
.catch((err) => console.error(err));
Place your signed license in public/tx-sheet-control-license.txt. The application reads this file before creating the editor.
Create the Component and Handle Readiness
Replace src/app/app.ts with this component. It configures the editor and implements the loading, editing, and download actions.
import { Component, OnInit, signal } from '@angular/core';
import { TXSheetControlComponent } from '@txtextcontrol/tx-sheet-control/angular';
import { StreamType, type Spreadsheet, type SpreadsheetOptions } from '@txtextcontrol/tx-sheet-control';
@Component({
selector: 'app-root',
standalone: true,
imports: [TXSheetControlComponent],
templateUrl: './app.html',
styleUrl: './app.css'
})
export class App implements OnInit {
readonly options = signal<SpreadsheetOptions | null>(null);
readonly status = signal('Reading the license...');
readonly isReady = signal(false);
readonly isBusy = signal(true);
private editor?: Spreadsheet;
ngOnInit(): void {
void this.initialize();
}
private async initialize(): Promise<void> {
try {
const response = await fetch(new URL('tx-sheet-control-license.txt', document.baseURI));
if (!response.ok) {
throw new Error('Provide public/tx-sheet-control-license.txt before starting the application.');
}
this.options.set({
license: await response.text(),
height: 'fill',
theme: 'light',
locale: 'en-US',
rows: 100,
columns: 20,
fontCatalogURL: new URL('assets/sheet/fonts/catalog.json', document.baseURI).href,
fontBaseURL: new URL('assets/sheet/fonts/', document.baseURI).href,
areas: { ribbon: true, formulaBar: true, sheetTabs: true, statusBar: true },
ribbon: {
layout: 'compact',
tabs: { reporting: { visible: false } },
buttons: { 'home.font.italic': { visible: false } }
}
});
this.status.set('Starting the spreadsheet editor...');
} catch (error) {
this.onError(error);
}
}
onReady(editor: Spreadsheet): void {
this.editor = editor;
const sheet = editor.workbook.sheets.at(0);
sheet.cell('A1').setText('Hello from Angular');
sheet.cell('A1').format({ bold: true, fontSize: 18, textColor: '#512178' });
sheet.columns.get('A').setWidth({ pixels: 280 });
this.isReady.set(true);
this.isBusy.set(false);
this.status.set('Ready. Load the sample XLSX to explore the workbook.');
}
onError(error: unknown): void {
this.isBusy.set(false);
this.status.set(error instanceof Error ? error.message : 'The editor could not be initialized.');
}
async loadSample(): Promise<void> {
await this.runAction(async (editor) => {
const response = await fetch(new URL('sales-report.xlsx', document.baseURI));
if (!response.ok) {
throw new Error('The sample XLSX could not be downloaded.');
}
const result = await editor.load(await response.arrayBuffer(), StreamType.SpreadsheetML);
this.status.set('Sample XLSX loaded.' + this.noticeText(result.warnings));
});
}
async openFile(input: HTMLInputElement): Promise<void> {
const file = input.files?.[0];
if (!file) {
return;
}
try {
await this.runAction(async (editor) => {
if (file.size > 10 * 1024 * 1024) {
throw new Error('Choose an XLSX file no larger than 10 MiB.');
}
const result = await editor.load(await file.arrayBuffer(), StreamType.SpreadsheetML);
this.status.set(file.name + ' loaded.' + this.noticeText(result.warnings));
});
} finally {
input.value = '';
}
}
async updateCells(): Promise<void> {
await this.runAction((editor) => {
const sheet = editor.workbook.sheets.at(0);
sheet.cell('A1').setText('Updated from Angular');
sheet.cell('B5').setValue(4);
sheet.cell('C5').setValue(120);
sheet.cell('D5').setFormula('=B5*C5');
sheet.cell('D10').setFormula('=SUM(D5:D8)');
sheet.range('B5:D5').format({ fillColor: '#ddf7f1' });
sheet.range('C5:D5').format({ numberFormatCode: '$#,##0.00' });
sheet.cell('D10').format({ numberFormatCode: '$#,##0.00', bold: true });
editor.ui.selectRange(sheet.range('D5'));
this.status.set('Cells updated. D5 = ' + sheet.cell('D5').value + '; grand total = ' + sheet.cell('D10').value + '.');
});
}
async downloadXlsx(): Promise<void> {
await this.runAction(async (editor) => {
const bytes = await editor.save(StreamType.SpreadsheetML);
const blob = new Blob([new Uint8Array(bytes).buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
});
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'angular-sales-report.xlsx';
document.body.append(link);
link.click();
link.remove();
setTimeout(() => URL.revokeObjectURL(url), 1000);
this.status.set('XLSX download started.');
});
}
private async runAction(action: (editor: Spreadsheet) => void | Promise<void>): Promise<void> {
if (!this.editor || this.isBusy()) {
return;
}
this.isBusy.set(true);
try {
await action(this.editor);
} catch (error) {
this.status.set('Operation failed: ' + (error instanceof Error ? error.message : String(error)));
} finally {
this.isBusy.set(false);
}
}
private noticeText(warnings: readonly unknown[]): string {
return warnings.length ? ' Review ' + warnings.length + ' conversion notice(s).' : '';
}
}
SpreadsheetOptions configures the license, light theme, number-formatting locale, and editor areas. The compact ribbon hides the Reporting tab and Italic button.
The ready event supplies the Spreadsheet instance used to access the workbook API. onReady writes a greeting into A1 and enables the buttons. The Angular component releases the editor when it is destroyed.
Add the Editor to the Angular Template
Replace src/app/app.html with this template. It creates the editor after the options are loaded and binds the readiness and initialization events.
<main>
<header>
<div>
<p class="eyebrow">ANGULAR · TX SHEET CONTROL</p>
<h1>Your Angular spreadsheet editor</h1>
<p class="intro">Load an Excel workbook, edit cells, and download the result.</p>
</div>
<span class="badge">Angular 22</span>
</header>
<section class="actions" aria-label="Workbook actions">
<button type="button" (click)="loadSample()" [disabled]="!isReady() || isBusy()">Load sample XLSX</button>
<button type="button" (click)="fileInput.click()" [disabled]="!isReady() || isBusy()">Open XLSX</button>
<input #fileInput id="open-workbook" type="file" accept=".xlsx" hidden (change)="openFile(fileInput)">
<button type="button" (click)="updateCells()" [disabled]="!isReady() || isBusy()">Update cells</button>
<button type="button" class="secondary" (click)="downloadXlsx()" [disabled]="!isReady() || isBusy()">Download XLSX</button>
</section>
<p id="sheet-status" class="status" role="status" aria-live="polite">{{ status() }}</p>
@if (options(); as editorOptions) {
<tx-sheet-control id="sales-editor" [options]="editorOptions"
(ready)="onReady($event)" (initializationError)="onError($event)" />
}
</main>
Add these styles to src/app/app.css. They give the editor a height of 640 pixels, matching the height: 'fill' option.
:host { display: block; padding: 32px 24px; }
main { max-width: 1280px; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
.eyebrow { color: #76299c; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; margin: 0 0 10px; }
h1 { color: #30223c; font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.intro { color: #6b6271; margin: 0; }
.badge { color: #76299c; background: #f0e5f7; border-radius: 20px; padding: 8px 14px; white-space: nowrap; font-size: 13px; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
button { font: inherit; border: 0; border-radius: 7px; padding: 11px 17px; background: #68228c; color: white; font-weight: 600; cursor: pointer; }
button.secondary { background: white; color: #68228c; box-shadow: inset 0 0 0 1px #cab8d6; }
button:disabled { opacity: .5; cursor: default; }
.status { min-height: 22px; color: #52645d; font-size: 14px; margin: 16px 0; }
tx-sheet-control { display: block; height: 640px; border: 1px solid #dcd5e4; border-radius: 10px; overflow: clip; background: white; }
@media (max-width: 600px) { :host { padding: 24px 12px; } header { gap: 12px; } h1 { font-size: 24px; } .badge { display: none; } }
For the same page appearance, use html, body { margin: 0; min-height: 100%; font-family: Arial, sans-serif; background: #f8f6fa; color: #30223c; } and * { box-sizing: border-box; } in src/styles.css.
Load XLSX Documents
Download the sample sales workbook (ZIP) and extract sales-report.xlsx into the public folder. It contains four service lines, editable formulas, and a grand total of $945.00. This is the workbook created in How to Create an Excel XLSX File in C# .NET.
Load the sample with fetch or read a selected file with File.arrayBuffer(). Pass the bytes to editor.load with StreamType.SpreadsheetML:
async loadSample(): Promise<void> {
await this.runAction(async (editor) => {
const response = await fetch(new URL('sales-report.xlsx', document.baseURI));
if (!response.ok) {
throw new Error('The sample XLSX could not be downloaded.');
}
const result = await editor.load(await response.arrayBuffer(), StreamType.SpreadsheetML);
this.status.set('Sample XLSX loaded.' + this.noticeText(result.warnings));
});
}
async openFile(input: HTMLInputElement): Promise<void> {
const file = input.files?.[0];
if (!file) {
return;
}
try {
await this.runAction(async (editor) => {
if (file.size > 10 * 1024 * 1024) {
throw new Error('Choose an XLSX file no larger than 10 MiB.');
}
const result = await editor.load(await file.arrayBuffer(), StreamType.SpreadsheetML);
this.status.set(file.name + ' loaded.' + this.noticeText(result.warnings));
});
} finally {
input.value = '';
}
}
The file picker accepts XLSX files up to 10 MiB. The load result includes any conversion notices in warnings.
Loading a document replaces the current workbook. Obtain fresh worksheet and cell handles before editing it.
Change Cell Text, Values, and Formulas with TypeScript
After selecting Load sample XLSX, select Update cells. The handler changes the report title, sets the consulting quantity to 4, writes a unit price of 120, and updates the amount and total formulas.
async updateCells(): Promise<void> {
await this.runAction((editor) => {
const sheet = editor.workbook.sheets.at(0);
sheet.cell('A1').setText('Updated from Angular');
sheet.cell('B5').setValue(4);
sheet.cell('C5').setValue(120);
sheet.cell('D5').setFormula('=B5*C5');
sheet.cell('D10').setFormula('=SUM(D5:D8)');
sheet.range('B5:D5').format({ fillColor: '#ddf7f1' });
sheet.range('C5:D5').format({ numberFormatCode: '$#,##0.00' });
sheet.cell('D10').format({ numberFormatCode: '$#,##0.00', bold: true });
editor.ui.selectRange(sheet.range('D5'));
this.status.set('Cells updated. D5 = ' + sheet.cell('D5').value + '; grand total = ' + sheet.cell('D10').value + '.');
});
}
Use setText for text, setValue for numbers, and setFormula for formulas beginning with =. Here, =B5*C5 evaluates to 480, and the grand total becomes 1,065.
format highlights the edited cells and applies currency formatting. editor.ui.selectRange selects D5 to show its formula, and cell.value returns the calculated result.
Export and Download an Excel Workbook
Download XLSX exports the current workbook with editor.save(StreamType.SpreadsheetML) and downloads the bytes as angular-sales-report.xlsx:
async downloadXlsx(): Promise<void> {
await this.runAction(async (editor) => {
const bytes = await editor.save(StreamType.SpreadsheetML);
const blob = new Blob([new Uint8Array(bytes).buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
});
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'angular-sales-report.xlsx';
document.body.append(link);
link.click();
link.remove();
setTimeout(() => URL.revokeObjectURL(url), 1000);
this.status.set('XLSX download started.');
});
}
Run and Build the Application
npm start
Open the development URL shown by the Angular CLI. Load the sample XLSX, update the cells, and confirm the status reports D5 = 480 and grand total = 1065. Download the result, then reopen it to check the edited quantity and formulas.
npm run build
Deploy dist/tx-sheet-control-angular/browser, including the public files, fonts, and language resources copied by the asset configuration.
Continue with the Angular integration guide, component API reference, and loading and saving guide.
Frequently Asked Questions
The example uses Angular 22 and TX Sheet Control 2.0.0 with a Node.js version supported by Angular 22.
Install the supplied npm archive and import TXSheetControlComponent from @txtextcontrol/tx-sheet-control/angular. Add it to the standalone component imports and use the tx-sheet-control element in the template.
Use a file input, read the selected file with File.arrayBuffer(), and pass the bytes to editor.load with StreamType.SpreadsheetML.
Use the Spreadsheet instance emitted by the ready event. Resolve worksheet and cell handles from its current workbook.
Call editor.save(StreamType.SpreadsheetML), then download the returned bytes as an XLSX file.
Bind the options to tx-sheet-control, provide the license and font catalog URL, and give the component a definite height.
Artwork includes an adapted Angular logo from the Angular team, available under CC BY 4.0.
TX Sheet Control
Excel-compatible spreadsheet editing, a robust calculation engine, and interactive dashboards for business applications.
Related Posts
How to Create an Excel XLSX File in C# .NET
Learn how to create an Excel XLSX file from scratch in C# .NET with TX Sheet Control. This step-by-step tutorial creates a sales workbook, writes text and numbers, adds formulas, applies currency…
Excel Compatibility in TX Sheet Control: Working with the Workbooks Your…
Learn how TX Sheet Control loads, edits, and saves Excel XLSX workbooks with their formulas, formatting, tables, charts, and native pivot tables. This article covers conversion diagnostics,…
Inside the TX Sheet Control Spreadsheet Editor: A Complete Spreadsheet for…
Learn how the TX Sheet Control spreadsheet editor brings a complete spreadsheet into JavaScript, Angular, ASP.NET Core, and Blazor applications. This article covers the ribbon, 522 formula…
TX Sheet Control 2.0 Is Now Available: Spreadsheets and Dashboards for Your…
Today, we are proud to officially release TX Sheet Control 2.0. The newest member of the Text Control product family brings Excel-compatible spreadsheet editing, a powerful calculation engine,…
Importing Excel XLSX Spreadsheets into TX Text Control in ASP.NET Core and…
TX Text Control is able to import Excel documents by converting spreadsheets into tables. This article shows how to import spreadsheets programmatically.
