Quickstart
This guide walks through the core Aspose.Cells FOSS for TypeScript workflow: creating a workbook from scratch, loading an existing XLSX file, styling cells, and exporting data to other formats. Each section below is a self-contained example you can copy into a Node.js project once the library is built from source.
Create a Workbook
Create a new Workbook, write typed values (strings and numbers) to cells with worksheet.putValue(), and save the result to an XLSX file:
import { Workbook } from "excel-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);
await workbook.save("report.xlsx");Load an Existing Workbook
Open an existing XLSX file with Workbook.load(), then read cell values back with worksheet.getCell(). This is the typical entry point for reading spreadsheet data produced by another tool:
import { Workbook } from "excel-cells";
const workbook = await Workbook.load("report.xlsx");
const worksheet = workbook.worksheets[0]!;
const product = worksheet.getCell(0, 0)?.value;
const revenue = worksheet.getCell(0, 1)?.value;
console.log(`${product}: ${revenue}`);Apply Styling
Create a Style object and apply font settings – name, size, bold, and color – before assigning it to a cell with cell.setStyle(). Styles are independent objects, so the same Style instance can be reused across many cells:
import { Workbook, Style } from "excel-cells";
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");Export to Multiple Formats
Call workbook.save() with a different file extension to export the same data to CSV, JSON, Markdown, or HTML – no separate conversion step is required:
import { Workbook } from "excel-cells";
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.xlsx");
await workbook.save("data.csv");
await workbook.save("data.json");
await workbook.save("data.md");