> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# JS API in Node

Import from `@reductoai/xlsx/node`. Its `ExcelWorkbook` is the [JS API](https://docs.reducto.ai/office/xlsx/js-api/concepts.md) plus file paths and export.

## Open, edit, save

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/node";

const book = await ExcelWorkbook.open("sales.xlsx");
const sheet = book.worksheets.getItem("Sheet1");
sheet.getRange("D1").values = [["Total"]];
sheet.getRange("D2:D3").formulas = [["=SUM(B2:C2)"], ["=SUM(B3:C3)"]];
sheet.getRange("D2:D3").numberFormat = "#,##0";
await book.save("sales.edited.xlsx");
```

`save` needs a destination path. It never writes over the file in place unless you pass the same path.

## Create

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/node";

const book = ExcelWorkbook.create();
const sheet = book.worksheets.getActiveWorksheet();
sheet.name = "Sales";
sheet.getRange("A1:C3").values = [
  ["Region", "Q1", "Q2"],
  ["North", 10, 12],
  ["South", 8, 15],
];
sheet.getRange("A1:C1").format.font.bold = true;
sheet.freezePanes.freezeRows(1);
await book.save("new.xlsx");
```

## Bytes

`ExcelWorkbook.fromBytes(bytes)` and `book.toBytes()` work without the file system, for a file from S3, an HTTP body or a database.

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/node";

const book = ExcelWorkbook.fromBytes(bytes);
book.worksheets.getItem("Sheet1").getRange("A1").values = [["Checked"]];
const out: Uint8Array = book.toBytes();
```

## Export

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/node";

const book = await ExcelWorkbook.open("model.xlsx");
await book.toPdf("model.pdf");
const [summary] = await book.toPng({ range: "Summary!A1:H30", scale: 2 });
```

See [PDF](https://docs.reducto.ai/office/xlsx/rendering/pdf.md) and [PNG](https://docs.reducto.ai/office/xlsx/rendering/png.md).
