Introduction

Aspose.Cells FOSS for TypeScript is a free, open-source library that lets developers create, read, modify, and export Excel spreadsheets directly from TypeScript applications. The library is MIT-licensed and has no dependency on Microsoft Office or any native runtime – it runs identically on Windows, Linux, and macOS.

The library provides a clean API built around Workbook, Worksheet, Cell, and Style classes. Developers can write cell values, set formulas, apply font and fill styling, add charts and shapes, configure data validation and auto-filters, and export to multiple formats including XLSX, CSV, JSON, Markdown, and HTML.

Install with a single command and start building spreadsheet automation pipelines, report generators, and data export tools without any Office dependency.


Key Features

Read and Write XLSX Files

Load existing workbooks with Workbook.load() and save with workbook.save(). Cell values, formulas, and styles round-trip through XLSX without loss. The WorksheetCollection class supports creating, removing, and reordering worksheets.

const workbook = await Workbook.load("input.xlsx");
const worksheet = workbook.worksheets[0]!;
console.log("A1:", worksheet.getCell(0, 0)?.value);
worksheet.putValue("B1", "Updated");
await workbook.save("output.xlsx");

Cell Values and Formulas

Write integers, decimals, and strings with worksheet.putValue(). Set formulas with cell.setFormula() – the formula string is stored verbatim in the XLSX file and evaluated by Excel or LibreOffice when opened.

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;
worksheet.putValue("A1", 42);
worksheet.putValue("A2", 3.14159);
worksheet.putValue("A3", "Hello World");
const cellA4 = worksheet.getCell2("A4");
cellA4.setFormula("=SUM(A1:A2)");
await workbook.save("formulas.xlsx");

Font and Fill Styling

Apply bold, italic, font size, font name, and font color using the Style class. Each cell can have its own independent style applied via cell.setStyle().

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;
const style = new Style();
style.setFontName("Arial");
style.setFontSize(14);
style.setBold(true);
style.setFontColor("FF0000");
const cell = worksheet.getCell2("A1");
cell.putValue("Styled Text");
cell.setStyle(style);
await workbook.save("styled.xlsx");

Multi-Format Export

Export workbooks to CSV, JSON, Markdown, and HTML using dedicated methods on Workbook: toCsv(), toJson(), toMarkdown(), and toHtml(). Alternatively, pass a file path with the desired extension to workbook.save().

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;
worksheet.putValue("A1", "Name");
worksheet.putValue("B1", "Age");
worksheet.putValue("A2", "Alice");
worksheet.putValue("B2", 25);
await workbook.save("data.csv");
await workbook.save("data.json");
await workbook.save("data.md");

Quick Start

Install the package with npm:

npm install @aspose/cells@1.0.0

Create a workbook, write data, apply styling, and save:

import { Workbook, Style } from "@aspose/cells";

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", "Product");
worksheet.putValue("B1", "Revenue");
worksheet.putValue("A2", "Widget");
worksheet.putValue("B2", 42000);
worksheet.putValue("A3", "Gadget");
worksheet.putValue("B3", 31500);

const headerStyle = new Style();
headerStyle.setBold(true);
headerStyle.setFontSize(12);
worksheet.getCell2("A1").setStyle(headerStyle);
worksheet.getCell2("B1").setStyle(headerStyle);

worksheet.setAutoFilter("A1:B3");
await workbook.save("report.xlsx");

Supported Formats

FormatExtensionReadWrite
XLSX.xlsx
CSV.csv
JSON.json
Markdown.md
HTML.html

Open Source & Licensing

Aspose.Cells FOSS for TypeScript is released under the MIT license. The source code is hosted on GitHub and accepts bug reports and pull requests. Commercial use is permitted under the MIT license terms.


Getting Started