Getting Started
Installation
How to install office-open packages
#Unified Package
Install the office-open unified package when you need multiple document types, CLI support, or AI integration:
pnpm add office-open
npm install office-open
yarn add office-open
bun add office-open
The unified package re-exports all document-specific packages and provides the CLI, JSON Schemas, and AI SDK tools.
#Individual Packages
Or install only the specific package(s) you need:
pnpm add @office-open/docx
pnpm add @office-open/pptx
pnpm add @office-open/xlsx
npm install @office-open/docx
npm install @office-open/pptx
npm install @office-open/xlsx
yarn add @office-open/docx
yarn add @office-open/pptx
yarn add @office-open/xlsx
bun add @office-open/docx
bun add @office-open/pptx
bun add @office-open/xlsx
Shared dependencies (@office-open/core, @office-open/xml) are pulled in automatically.
#Browser
For browser usage, import directly from a CDN that supports ESM:
<script type="module">
import { generateDocument } from "https://esm.sh/@office-open/docx";
// ... create and export your document
</script>
Or use a bundler (Vite, Webpack, etc.) — the packages ship as standard ESM modules and work out of the box.
#TypeScript
All packages are written in TypeScript and ship with complete type definitions, providing full autocomplete and type safety.
import { generateDocument } from "@office-open/docx";
// Full type support and autocomplete
const buffer = await generateDocument({
sections: [
{
children: [{ paragraph: { children: [{ text: "Hello, World!", bold: true }] } }],
},
],
});
#Requirements
- Node.js >= 18
- TypeScript >= 5.0 (optional, but recommended)