Token导航 LogoToken导航

Agent Skill · 前端设计

office(office 文档)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

office 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证为 MIT,第三方扫描有提醒项,按安装量在前端设计类的 10,216 个 Skill 里排第 865。

总安装 10,531周安装 426GitHub Stars 750下载 3,306核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:office(office 文档)
来源仓库:https://github.com/jezweb/claude-skills
仓库路径:skills/office
安装命令:
npx skills add https://github.com/jezweb/claude-skills --skill office
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/jezweb/claude-skills --skill office

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

使用纯 JavaScript 生成 Microsoft Office 文档和 PDF,无本机依赖项。

使用 TypeScript 创建 DOCX、XLSX、PDF 和 PPTX 文件;所有库都在 Node.js、浏览器和 Cloudflare Workers 中运行 DOCX 支持段落、表格、图像和文本格式; XLSX 处理公式、多个工作表以及 JSON 到工作表的转换 PDF 包括文本、形状、图像、表格填写和页面合并; PPTX 涵盖幻灯片、图表、表格和主布局 常见陷阱:记住 PDF 坐标从左下角开始,始终等待 Packer.toBuffer() 对于 DOCX,在 Workers 中使用 base64 图像而不是远程 URL

来源仓库内路径:skills/office

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/jezweb/claude-skills --skill office;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

office 怎么安装?

在终端执行 npx skills add https://github.com/jezweb/claude-skills --skill office。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

office 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

office 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

office 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

office 用的人多吗?

公开数据是累计安装 10,531 次,近一周安装 426 次,下载 3,306 次,GitHub 750 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

office 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
office

office 文档 · 本页

10,531750操作浏览器MIT有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Office Document Generation

Status: Production Ready Last Updated: 2026-01-12 Dependencies: None (pure JavaScript libraries) Latest Versions: docx@9.5.0, xlsx@0.18.5, pdf-lib@1.17.1, pptxgenjs@4.0.1


Overview

Generate Microsoft Office documents and PDFs programmatically with TypeScript. All libraries are pure JavaScript with zero native dependencies, enabling universal runtime support:

FormatLibraryWorkersBrowserNode.js
DOCXdocx✅✅✅
XLSXxlsx (SheetJS)✅✅✅
PDFpdf-lib✅✅✅
PPTXpptxgenjs⚠️*✅✅

*PPTX in Workers: Works for local images/data. Remote image fetching needs workaround (uses https module).


Quick Start

Installation

# Install all four (or pick what you need)
npm install docx xlsx pdf-lib pptxgenjs

Create a Word Document (30 seconds)

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);

Create an Excel Spreadsheet (30 seconds)

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' });

Create a PDF (30 seconds)

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);

Create a PowerPoint (30 seconds)

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 Documents

Key Concepts

The docx package uses a builder pattern:

  • Document - The root container
  • Section - Contains pages (most docs have 1 section)
  • Paragraph - A line/block of text
  • TextRun - Formatted text within a paragraph
  • Table - Grid of TableRow → TableCell → Paragraph

Document with Headings and Paragraphs

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.'),
        ],
      }),
    ],
  }],
});

Tables

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] }],
});

Images

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',
          }),
        ],
      }),
    ],
  }],
});

Export Patterns

// 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 Spreadsheets

Key Concepts

SheetJS (xlsx) uses utility functions:

  • Workbook - Container for sheets
  • Worksheet - Single sheet (grid of cells)
  • utils.aoa_to_sheet - Array of arrays → worksheet
  • utils.json_to_sheet - JSON array → worksheet
  • utils.book_new/book_append_sheet - Create/add sheets

From Array of Arrays

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');

From 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');

Column Widths

// Set column widths (in characters)
ws['!cols'] = [
  { wch: 10 },  // Column A
  { wch: 20 },  // Column B
  { wch: 15 },  // Column C
];

Multiple Sheets

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');

Export Patterns

// 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 Documents

Key Concepts

pdf-lib uses a page-based approach:

  • PDFDocument - The PDF file
  • PDFPage - Individual page
  • Coordinates - Origin at BOTTOM-LEFT (not top-left!)
  • Units - Points (72 points = 1 inch)

Standard Page Sizes

// 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"

Text and Fonts

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),
});

Drawing Shapes

// 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),
});

Images

// 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,
});

Fill PDF Forms

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();

Merge PDFs

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 Presentations

Key Concepts

pptxgenjs uses a slide-based approach:

  • Presentation - The PPTX file (new pptxgen())
  • Slide - Individual slide (addSlide())
  • Elements - Text, images, shapes, tables, charts
  • Units - Inches by default (can change to cm/points)

Basic Presentation

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',
});

Slide with Bullet Points

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' });

Tables

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',
});

Charts

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,
});

Images

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,
});

Shapes

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' },
});

Slide Layouts and Masters

// 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' });

Export Patterns

// 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 Integration

All four libraries work in Cloudflare Workers (PPTX with caveats for remote images).

DOCX Generation Endpoint

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 to PDF with Browser Rendering

For complex layouts with CSS, use Cloudflare Browser Rendering (paid feature):

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 binding:

{
  "browser": {
    "binding": "BROWSER"
  }
}

Critical Rules

Always Do

✅ Use await Packer.toBuffer() for DOCX (it's async) ✅ Remember PDF coordinates start at BOTTOM-LEFT ✅ Use type: 'buffer' for XLSX in Workers/browser ✅ Embed fonts in PDF before using them ✅ Set proper Content-Type headers for downloads ✅ Use await pptx.writeFile() or await pptx.write() for PPTX ✅ Use base64 images in PPTX for Workers (avoid remote URLs)

Never Do

❌ Use Packer.toBuffer() without await (returns Promise) ❌ Assume PDF y=0 is at top (it's at bottom) ❌ Use writeFile in Workers (use Response instead) ❌ Forget to set Content-Disposition for downloads ❌ Use Node.js fs module in browser/Workers ❌ Use PPTX path URLs in Workers (https module not available)


Known Issues Prevention

Issue #1: DOCX Packer Returns Promise

Error: [object Promise] in file or empty document Why: Packer.toBuffer() is async but called without await Prevention: Always await Packer.toBuffer(doc)

Issue #2: PDF Text at Wrong Position

Error: Text appears at bottom of page or off-page Why: PDF coordinates have origin at bottom-left, not top-left Prevention: For text near top, use high y values (e.g., y=750 for letter size)

Issue #3: XLSX Formula Not Calculating

Error: Cell shows formula text instead of result Why: SheetJS doesn't execute formulas, Excel does on open Prevention: This is expected - formulas calculate when opened in Excel

Issue #4: Workers DOCX/PDF Returns Empty

Error: Downloaded file is empty or corrupted Why: Returning wrong type or missing Content-Type header Prevention: Return buffer directly with proper headers

Issue #5: PPTX Remote Images Fail in Workers

Error: https is not defined or image not appearing Why: pptxgenjs uses Node.js https module for remote images Prevention: Use base64 data URIs or local images in Workers environment


Using Bundled Resources

Templates (templates/)

  • docx-basic.ts - Complete Word document with headings, tables, images
  • xlsx-basic.ts - Excel workbook with formulas and formatting
  • pdf-basic.ts - PDF with text, images, shapes
  • pptx-basic.ts - PowerPoint with slides, charts, tables
  • workers-pdf.ts - Cloudflare Workers PDF generation example

References (references/)

  • docx-api.md - Quick reference for docx npm package
  • xlsx-api.md - Quick reference for SheetJS functions
  • pdf-lib-api.md - Quick reference for pdf-lib methods
  • pptxgenjs-api.md - Quick reference for pptxgenjs

Scripts (scripts/)

  • verify-deps.sh - Check library versions are current

Limitations vs Anthropic's Official Skills

This skill focuses on document creation with portable TypeScript libraries:

FeatureThis SkillAnthropic's Skills
Create DOCX/XLSX/PDF/PPTX✅✅
Works in Cloudflare Workers✅❌
Plugin installable✅❌
TypeScript-first✅❌ (Python)
Edit existing DOCX with tracked changes❌✅
Excel formula validation❌✅
OCR scanned PDFs❌✅

For advanced editing scenarios (tracked changes, formula validation), consider Anthropic's official skills with Python tooling.


Package Versions (Verified 2026-01-12)

{
  "dependencies": {
    "docx": "^9.5.0",
    "xlsx": "^0.18.5",
    "pdf-lib": "^1.17.1",
    "pptxgenjs": "^4.0.1"
  }
}

Official Documentation


Complete Setup Checklist

  • Installed required packages (npm install docx xlsx pdf-lib)
  • Verified import statements match runtime (Node.js vs browser)
  • Used proper export method for target environment
  • Set Content-Type headers for HTTP responses
  • Tested document opens correctly in target application
  • Confirmed Workers compatibility (if deploying to edge)

平台分布

Claude Code

28.62%
按下载量换算946

Gemini CLI

22.07%
按下载量换算730

Cursor

17.05%
按下载量换算564

Antigravity

13.36%
按下载量换算442

OpenCode

6.81%
按下载量换算225

Codex

3.38%
按下载量换算112

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills