关于 office
面向需要用 TypeScript 程序化生成办公文档的开发者,介绍 DOCX、XLSX、PDF 和 PPTX 的 JavaScript 库及用法。指南也说明浏览器、Node.js 和 Workers 环境中的导出方式与注意事项。
主要功能
- 01生成 DOCX 文档与表格
- 02创建 XLSX 工作簿和工作表
- 03创建、编辑及合并 PDF
- 04制作含图表和图像的 PPTX
- 05浏览器、Node.js 与 Workers 导出模式
- 06格式相关问题排查
适用场景
- 01从应用数据生成 Word 报告
- 02将记录导出为 Excel 工作簿
- 03填写表单或合并 PDF 文件
- 04通过 API 生成并返回文档下载
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ jezweb/ claude-skills --skill office安装后在 Claude Code 中输入/office确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.md.claude-plugin/plugin.jsonagents/office-docs.mdreferences/docx-api.mdpdf-lib-api.mdpptxgenjs-api.mdxlsx-api.mdrules/office.mdscripts/verify-deps.shtemplates/docx-basic.tspdf-basic.tspptx-basic.tsworkers-pdf.tsxlsx-basic.ts详细介绍
Office 文档生成
状态:已可用于生产环境 最后更新:2026-01-12 依赖项:无(纯 JavaScript 库) 最新版本:[email protected]、[email protected]、[email protected]、[email protected]
概述
使用 TypeScript 以编程方式生成 Microsoft Office 文档和 PDF。所有库均为纯 JavaScript,不依赖任何原生组件,因此可在各种运行时环境中使用:
| 格式 | 库 | Workers | 浏览器 | Node.js |
|---|---|---|---|---|
| DOCX | docx | ✅ | ✅ | ✅ |
| XLSX | xlsx (SheetJS) | ✅ | ✅ | ✅ |
pdf-lib | ✅ | ✅ | ✅ | |
| PPTX | pptxgenjs | ⚠️* | ✅ | ✅ |
*Workers 中的 PPTX:可处理本地图片/数据。获取远程图片需要采用变通方案(使用 https 模块)。
快速开始
安装
# Install all four (or pick what you need)
npm install docx xlsx pdf-lib pptxgenjs
创建 Word 文档(30 秒)
import { Document, Packer, Paragraph, TextRun } from 'docx';
import { writeFileSync } from 'fs';
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new TextRun({ text: 'Hello World', bold: true, size: 48 }),
],
}),
],
}],
});
// Node.js: Save to file
const buffer = await Packer.toBuffer(doc);
writeFileSync('hello.docx', buffer);
// Browser/Workers: Get as blob
const blob = await Packer.toBlob(doc);
创建 Excel 电子表格(30 秒)
import * as XLSX from 'xlsx';
// Create workbook with data
const data = [
['Name', 'Amount', 'Date'],
['Invoice #1', 1500, '2026-01-12'],
['Invoice #2', 2300, '2026-01-13'],
];
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Invoices');
// Node.js: Save to file
XLSX.writeFile(workbook, 'invoices.xlsx');
// Browser/Workers: Get as buffer
const buffer = XLSX.write(workbook, { type: 'buffer', bookType: 'xlsx' });
创建 PDF(30 秒)
import { PDFDocument, StandardFonts, rgb } from 'pdf-lib';
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage([612, 792]); // Letter size
const font = await pdfDoc.embedFont(StandardFonts.Helvetica);
page.drawText('Hello World', {
x: 50,
y: 700,
size: 24,
font,
color: rgb(0, 0, 0),
});
// Get as bytes (works everywhere)
const pdfBytes = await pdfDoc.save();
// Node.js: Save to file
writeFileSync('hello.pdf', pdfBytes);
创建 PowerPoint 演示文稿(30 秒)
import pptxgen from 'pptxgenjs';
const pptx = new pptxgen();
pptx.author = 'Your Name';
pptx.title = 'Sample Presentation';
// Add a slide
const slide = pptx.addSlide();
slide.addText('Hello World', {
x: 1, y: 1, w: 8, h: 1.5,
fontSize: 36, bold: true, color: '363636',
});
// Node.js: Save to file
await pptx.writeFile({ fileName: 'hello.pptx' });
// Browser: Trigger download
await pptx.writeFile({ fileName: 'hello.pptx' });
DOCX:Word 文档
核心概念
docx 包采用构建器模式:
- Document - 根容器
- Section - 包含页面(大多数文档只有 1 个节)
- Paragraph - 一行/一块文本
- TextRun - 段落中的格式化文本
- Table - 表格网格,由 TableRow → TableCell → Paragraph 构成
带标题和段落的文档
import { Document, Packer, Paragraph, TextRun, HeadingLevel } from 'docx';
const doc = new Document({
sections: [{
children: [
new Paragraph({
text: 'Monthly Report',
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
children: [
new TextRun('This is a '),
new TextRun({ text: 'bold', bold: true }),
new TextRun(' and '),
new TextRun({ text: 'italic', italics: true }),
new TextRun(' text example.'),
],
}),
],
}],
});
表格
import { Document, Table, TableRow, TableCell, Paragraph, WidthType } from 'docx';
const table = new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
new TableCell({ children: [new Paragraph('Header 1')] }),
new TableCell({ children: [new Paragraph('Header 2')] }),
],
}),
new TableRow({
children: [
new TableCell({ children: [new Paragraph('Data 1')] }),
new TableCell({ children: [new Paragraph('Data 2')] }),
],
}),
],
});
const doc = new Document({
sections: [{ children: [table] }],
});
图片
import { Document, Paragraph, ImageRun } from 'docx';
import { readFileSync } from 'fs';
const imageBuffer = readFileSync('logo.png');
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new ImageRun({
data: imageBuffer,
transformation: { width: 200, height: 100 },
type: 'png',
}),
],
}),
],
}],
});
导出方式
// Node.js - Save to file
import { writeFileSync } from 'fs';
const buffer = await Packer.toBuffer(doc);
writeFileSync('document.docx', buffer);
// Browser - Download
const blob = await Packer.toBlob(doc);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.docx';
a.click();
// Cloudflare Workers - Return as Response
const buffer = await Packer.toBuffer(doc);
return new Response(buffer, {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'Content-Disposition': 'attachment; filename="document.docx"',
},
});
XLSX:Excel 电子表格
核心概念
SheetJS (xlsx) 使用实用函数:
- Workbook - 工作表容器
- Worksheet - 单个工作表(单元格网格)
- utils.aoa_to_sheet - 二维数组 → 工作表
- utils.json_to_sheet - JSON 数组 → 工作表
- utils.book_new/book_append_sheet - 创建/添加工作表
从二维数组创建
import * as XLSX from 'xlsx';
const data = [
['Product', 'Price', 'Quantity', 'Total'],
['Widget A', 10, 5, { f: 'B2*C2' }], // Formula
['Widget B', 15, 3, { f: 'B3*C3' }],
['', '', 'Grand Total:', { f: 'SUM(D2:D3)' }],
];
const ws = XLSX.utils.aoa_to_sheet(data);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sales');
从 JSON 创建
const invoices = [
{ id: 1, customer: 'Acme Corp', amount: 1500, date: '2026-01-12' },
{ id: 2, customer: 'Globex', amount: 2300, date: '2026-01-13' },
];
const ws = XLSX.utils.json_to_sheet(invoices);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Invoices');
列宽
// Set column widths (in characters)
ws['!cols'] = [
{ wch: 10 }, // Column A
{ wch: 20 }, // Column B
{ wch: 15 }, // Column C
];
多个工作表
const wb = XLSX.utils.book_new();
const summaryData = [['Total Sales', 3800]];
const detailData = [['Item', 'Amount'], ['Item 1', 1500], ['Item 2', 2300]];
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(summaryData), 'Summary');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(detailData), 'Details');
导出方式
// Node.js - Save to file
XLSX.writeFile(workbook, 'report.xlsx');
// Browser/Workers - Get buffer
const buffer = XLSX.write(workbook, { type: 'buffer', bookType: 'xlsx' });
// Cloudflare Workers - Return as Response
return new Response(buffer, {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition': 'attachment; filename="report.xlsx"',
},
});
PDF:PDF 文档
核心概念
pdf-lib 采用基于页面的方式:
- PDFDocument - PDF 文件
- PDFPage - 单个页面
- 坐标 - 原点位于左下角(不是左上角!)
- 单位 - 点(72 点 = 1 英寸)
标准页面尺寸
// Common sizes in points [width, height]
const LETTER = [612, 792]; // 8.5" x 11"
const A4 = [595.28, 841.89]; // 210mm x 297mm
const LEGAL = [612, 1008]; // 8.5" x 14"
文本和字体
import { PDFDocument, StandardFonts, rgb } from 'pdf-lib';
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage([612, 792]);
// Embed standard fonts
const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica);
const helveticaBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
// Draw text (y=0 is BOTTOM of page)
page.drawText('Invoice #12345', {
x: 50,
y: 750, // Near top of page
size: 24,
font: helveticaBold,
color: rgb(0, 0, 0),
});
page.drawText('Thank you for your business!', {
x: 50,
y: 50, // Near bottom of page
size: 12,
font: helvetica,
color: rgb(0.5, 0.5, 0.5),
});
绘制形状
// Rectangle
page.drawRectangle({
x: 50,
y: 600,
width: 200,
height: 100,
borderColor: rgb(0, 0, 0),
borderWidth: 1,
color: rgb(0.95, 0.95, 0.95), // Fill color
});
// Line
page.drawLine({
start: { x: 50, y: 500 },
end: { x: 550, y: 500 },
thickness: 1,
color: rgb(0, 0, 0),
});
图片
// From URL/fetch
const imageBytes = await fetch('https://example.com/logo.png').then(r => r.arrayBuffer());
const image = await pdfDoc.embedPng(imageBytes);
// Or embedJpg for JPEG
// const image = await pdfDoc.embedJpg(imageBytes);
page.drawImage(image, {
x: 50,
y: 700,
width: 100,
height: 50,
});
填写 PDF 表单
import { PDFDocument } from 'pdf-lib';
// Load existing PDF with form
const existingPdfBytes = await fetch('form.pdf').then(r => r.arrayBuffer());
const pdfDoc = await PDFDocument.load(existingPdfBytes);
// Get form and fields
const form = pdfDoc.getForm();
const nameField = form.getTextField('customer_name');
const dateField = form.getTextField('date');
// Fill fields
nameField.setText('John Doe');
dateField.setText('2026-01-12');
// Flatten form (make fields non-editable)
form.flatten();
const pdfBytes = await pdfDoc.save();
合并 PDF
import { PDFDocument } from 'pdf-lib';
const pdf1Bytes = await fetch('doc1.pdf').then(r => r.arrayBuffer());
const pdf2Bytes = await fetch('doc2.pdf').then(r => r.arrayBuffer());
const mergedPdf = await PDFDocument.create();
const pdf1 = await PDFDocument.load(pdf1Bytes);
const pdf2 = await PDFDocument.load(pdf2Bytes);
// Copy all pages from both documents
const pages1 = await mergedPdf.copyPages(pdf1, pdf1.getPageIndices());
const pages2 = await mergedPdf.copyPages(pdf2, pdf2.getPageIndices());
pages1.forEach(page => mergedPdf.addPage(page));
pages2.forEach(page => mergedPdf.addPage(page));
const mergedBytes = await mergedPdf.save();
PPTX:PowerPoint 演示文稿
核心概念
pptxgenjs 采用基于幻灯片的方式:
- Presentation - PPTX 文件(new pptxgen())
- Slide - 单张幻灯片(addSlide())
- 元素 - 文本、图片、形状、表格、图表
- 单位 - 默认使用英寸(可更改为厘米/点)
基本演示文稿
import pptxgen from 'pptxgenjs';
const pptx = new pptxgen();
pptx.author = 'Author Name';
pptx.title = 'Presentation Title';
pptx.subject = 'Subject';
pptx.company = 'Company';
// Title slide
const titleSlide = pptx.addSlide();
titleSlide.addText('Quarterly Report', {
x: 0.5, y: 2, w: 9, h: 1,
fontSize: 44, bold: true, color: '0066CC', align: 'center',
});
titleSlide.addText('Q1 2026', {
x: 0.5, y: 3.5, w: 9, h: 0.5,
fontSize: 24, color: '666666', align: 'center',
});
带项目符号的幻灯片
const contentSlide = pptx.addSlide();
// Title
contentSlide.addText('Key Highlights', {
x: 0.5, y: 0.5, w: 9, h: 0.8,
fontSize: 32, bold: true, color: '333333',
});
// Bullet points
contentSlide.addText([
{ text: 'Revenue up 25% YoY', options: { bullet: true, fontSize: 20 } },
{ text: 'Customer base grew to 10,000', options: { bullet: true, fontSize: 20 } },
{ text: 'New product launch successful', options: { bullet: true, fontSize: 20 } },
{ text: 'Expanded to 5 new markets', options: { bullet: true, fontSize: 20 } },
], { x: 0.5, y: 1.5, w: 8, h: 4, valign: 'top' });
表格
const tableSlide = pptx.addSlide();
tableSlide.addText('Sales Summary', {
x: 0.5, y: 0.5, w: 9, h: 0.8,
fontSize: 28, bold: true,
});
const tableData = [
[{ text: 'Region', options: { bold: true, fill: '0066CC', color: 'FFFFFF' } },
{ text: 'Q1', options: { bold: true, fill: '0066CC', color: 'FFFFFF' } },
{ text: 'Q2', options: { bold: true, fill: '0066CC', color: 'FFFFFF' } }],
['North America', '$2.5M', '$2.8M'],
['Europe', '$1.8M', '$2.1M'],
['Asia Pacific', '$1.2M', '$1.5M'],
];
tableSlide.addTable(tableData, {
x: 0.5, y: 1.5, w: 9,
border: { pt: 1, color: 'CCCCCC' },
fontFace: 'Arial',
fontSize: 14,
align: 'center',
valign: 'middle',
});
图表
const chartSlide = pptx.addSlide();
chartSlide.addText('Revenue Trend', {
x: 0.5, y: 0.5, w: 9, h: 0.6,
fontSize: 28, bold: true,
});
chartSlide.addChart(pptx.ChartType.line, [
{ name: 'Revenue', labels: ['Jan', 'Feb', 'Mar', 'Apr'], values: [100, 120, 150, 180] },
{ name: 'Expenses', labels: ['Jan', 'Feb', 'Mar', 'Apr'], values: [80, 85, 90, 95] },
], {
x: 0.5, y: 1.2, w: 9, h: 4,
showLegend: true,
legendPos: 'b',
showTitle: false,
});
图片
import { readFileSync } from 'fs';
const imageSlide = pptx.addSlide();
// From file (Node.js)
imageSlide.addImage({
path: 'logo.png',
x: 0.5, y: 0.5, w: 2, h: 1,
});
// From base64
const imageBase64 = readFileSync('chart.png').toString('base64');
imageSlide.addImage({
data: `image/png;base64,${imageBase64}`,
x: 0.5, y: 2, w: 4, h: 3,
});
// From URL (Node.js only - uses https module)
imageSlide.addImage({
path: 'https://example.com/image.png',
x: 5, y: 2, w: 4, h: 3,
});
形状
const shapeSlide = pptx.addSlide();
// Rectangle
shapeSlide.addShape(pptx.ShapeType.rect, {
x: 0.5, y: 0.5, w: 3, h: 2,
fill: { color: '0066CC' },
line: { color: '004499', pt: 2 },
});
// Circle/Oval
shapeSlide.addShape(pptx.ShapeType.ellipse, {
x: 4, y: 0.5, w: 2, h: 2,
fill: { color: '00AA00' },
});
// Arrow
shapeSlide.addShape(pptx.ShapeType.rightArrow, {
x: 1, y: 3, w: 3, h: 1,
fill: { color: 'FF6600' },
});
幻灯片布局和母版
// Define a master slide
pptx.defineSlideMaster({
title: 'COMPANY_MASTER',
background: { color: 'FFFFFF' },
objects: [
{ text: { text: 'Company Name', options: { x: 0.5, y: 0.2, w: 4, h: 0.3, fontSize: 10, color: '999999' } } },
{ line: { x: 0.5, y: 0.6, w: 9, h: 0, line: { color: '0066CC', pt: 2 } } },
],
});
// Use the master
const slide = pptx.addSlide({ masterName: 'COMPANY_MASTER' });
导出方式
// Node.js - Save to file
await pptx.writeFile({ fileName: 'presentation.pptx' });
// Browser - Trigger download
await pptx.writeFile({ fileName: 'presentation.pptx' });
// Get as base64 (for email, API, etc.)
const base64 = await pptx.write({ outputType: 'base64' });
// Get as Blob (browser)
const blob = await pptx.write({ outputType: 'blob' });
// Get as ArrayBuffer
const arrayBuffer = await pptx.write({ outputType: 'arraybuffer' });
// Cloudflare Workers - Return as Response
const arrayBuffer = await pptx.write({ outputType: 'arraybuffer' });
return new Response(arrayBuffer, {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'Content-Disposition': 'attachment; filename="presentation.pptx"',
},
});
Cloudflare Workers 集成
这四个库均可在 Cloudflare Workers 中使用(PPTX 获取远程图片时有一些限制)。
DOCX 生成端点
import { Hono } from 'hono';
import { Document, Packer, Paragraph, TextRun } from 'docx';
const app = new Hono();
app.get('/api/invoice/:id', async (c) => {
const invoiceId = c.req.param('id');
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [new TextRun({ text: `Invoice #${invoiceId}`, bold: true, size: 48 })],
}),
],
}],
});
const buffer = await Packer.toBuffer(doc);
return new Response(buffer, {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'Content-Disposition': `attachment; filename="invoice-${invoiceId}.docx"`,
},
});
});
export default app;
使用浏览器渲染将 HTML 转为 PDF
对于包含 CSS 的复杂布局,可使用 Cloudflare Browser Rendering(付费功能):
import puppeteer from '@cloudflare/puppeteer';
export default {
async fetch(request, env) {
const browser = await puppeteer.launch(env.BROWSER);
const page = await browser.newPage();
// Set HTML content
await page.setContent(`
<html>
<head>
<style>
body { font-family: Arial, sans-serif; padding: 40px; }
h1 { color: #333; }
table { width: 100%; border-collapse: collapse; }
td, th { border: 1px solid #ddd; padding: 8px; }
</style>
</head>
<body>
<h1>Invoice #12345</h1>
<table>
<tr><th>Item</th><th>Amount</th></tr>
<tr><td>Service</td><td>$500</td></tr>
</table>
</body>
</html>
`);
const pdf = await page.pdf({ format: 'A4' });
await browser.close();
return new Response(pdf, {
headers: {
'Content-Type': 'application/pdf',
'Content-Disposition': 'attachment; filename="invoice.pdf"',
},
});
},
};
wrangler.jsonc 绑定:
{
"browser": {
"binding": "BROWSER"
}
}
关键规则
务必做到
✅ 对 DOCX 使用 await Packer.toBuffer()(这是异步操作)
✅ 记住 PDF 坐标原点位于左下角
✅ 在 Workers/浏览器中为 XLSX 使用 type: 'buffer'
✅ 使用字体前先将其嵌入 PDF
✅ 为下载设置正确的 Content-Type 标头
✅ 对 PPTX 使用 await pptx.writeFile() 或 await pptx.write()
✅ 在 Workers 中对 PPTX 使用 base64 图片(避免使用远程 URL)
切勿
❌ 不要在未使用 await 的情况下调用 Packer.toBuffer()(它会返回 Promise)
❌ 不要假设 PDF 的 y=0 位于顶部(它位于底部)
❌ 不要在 Workers 中使用 writeFile(改用 Response)
❌ 不要忘记为下载设置 Content-Disposition
❌ 不要在浏览器/Workers 中使用 Node.js fs 模块
❌ 不要在 Workers 中使用 PPTX 路径 URL(无法使用 https 模块)
预防已知问题
问题 #1:DOCX Packer 返回 Promise
错误:文件中出现 [object Promise] 或文档为空
原因:Packer.toBuffer() 是异步的,但调用时未使用 await
预防:始终使用 await Packer.toBuffer(doc)
问题 #2:PDF 文本位置错误
错误:文本出现在页面底部或页面之外 原因:PDF 坐标原点位于左下角,而非左上角 预防:将文本放在靠近顶部的位置时,使用较大的 y 值(例如,信纸尺寸页面使用 y=750)
问题 #3:XLSX 公式未计算
错误:单元格显示公式文本而非结果 原因:SheetJS 不会执行公式,Excel 会在打开文件时计算 预防:这是预期行为——在 Excel 中打开时会计算公式
问题 #4:Workers DOCX/PDF 返回空文件
错误:下载的文件为空或已损坏 原因:返回了错误的类型或缺少 Content-Type 标头 预防:直接返回缓冲区,并设置正确的标头
问题 #5:Workers 中的 PPTX 远程图片加载失败
错误:出现 https is not defined,或图片未显示
原因:pptxgenjs 使用 Node.js 的 https 模块加载远程图片
预防:在 Workers 环境中使用 base64 数据 URI 或本地图片
使用捆绑资源
模板(templates/)
docx-basic.ts- 包含标题、表格和图片的完整 Word 文档xlsx-basic.ts- 包含公式和格式的 Excel 工作簿pdf-basic.ts- 包含文本、图片和形状的 PDFpptx-basic.ts- 包含幻灯片、图表和表格的 PowerPointworkers-pdf.ts- Cloudflare Workers 生成 PDF 的示例
参考文档(references/)
docx-api.md- docx npm 包的快速参考xlsx-api.md- SheetJS 函数的快速参考pdf-lib-api.md- pdf-lib 方法的快速参考pptxgenjs-api.md- pptxgenjs 的快速参考
脚本(scripts/)
verify-deps.sh- 检查库版本是否为最新
与 Anthropic 官方技能的限制对比
此技能专注于使用可移植的 TypeScript 库创建文档:
| 功能 | 此技能 | Anthropic 的技能 |
|---|---|---|
| 创建 DOCX/XLSX/PDF/PPTX | ✅ | ✅ |
| 可在 Cloudflare Workers 中运行 | ✅ | ❌ |
| 可安装插件 | ✅ | ❌ |
| 优先使用 TypeScript | ✅ | ❌(Python) |
| 编辑已有 DOCX 并保留修订记录 | ❌ | ✅ |
| 验证 Excel 公式 | ❌ | ✅ |
| 对扫描版 PDF 进行 OCR | ❌ | ✅ |
对于高级编辑场景(修订记录、公式验证),可以考虑使用搭配 Python 工具的 Anthropic 官方技能。
软件包版本(已于 2026-01-12 验证)
{
"dependencies": {
"docx": "^9.5.0",
"xlsx": "^0.18.5",
"pdf-lib": "^1.17.1",
"pptxgenjs": "^4.0.1"
}
}
官方文档
- docx:https://docx.js.org/
- SheetJS (xlsx):https://docs.sheetjs.com/
- pdf-lib:https://pdf-lib.js.org/
- pptxgenjs:https://gitbrent.github.io/PptxGenJS/
- Cloudflare Browser Rendering:https://developers.cloudflare.com/browser-rendering/
完整设置检查清单
- 已安装所需软件包(
npm install docx xlsx pdf-lib) - 已确认导入语句与运行环境(Node.js 或浏览器)相符
- 已针对目标环境使用正确的导出方法
- 已为 HTTP 响应设置 Content-Type 标头
- 已测试文档能否在目标应用程序中正确打开
- 已确认与 Workers 兼容(如部署到边缘环境)