A simplified AI Skill for generating Word documents from Word templates and JSON data. This is a free simplified version of full-featured Sheet-to-Doc product.
Features
- Document Generation: Replace
{field}placeholders in Word templates with JSON data - Placeholder Extraction: Extract all placeholder keys from templates for data validation
- Footer Mark: Automatically adds footer attribution to generated documents
- Cross-Platform: Works on Windows, macOS, and Linux
- Command Line Interface: Easy to use via terminal
- API Access: Import as a module for programmatic use
Requirements
- Node.js 18+
- docxtemplater
- pizzip
Installation
OpenClaw Installation
npm install -g openclaw
openclaw skills install @he-yang/sheet-to-doc-skill
Skills Installation
npx skills add https://github.com/he-yang/sheet-to-doc-skill --skill sheet-to-doc-skill
Quick Start
1. Create a Word Template
Create a .docx file with {field} format placeholders:
1 | Dear {name}, |
2. Prepare JSON Data
1 | { |
3. Generate Document
Using Command Line
1 | # Basic usage |
Using API
1 | import { generateDocument } from './scripts/generate.js'; |
Placeholder Extraction
Extract required placeholders from a template to validate your data:
1 | # Extract placeholders |
Output:
1 | { |
API Usage
1 | import { extractPlaceholders } from './scripts/generate.js'; |
Command Line Options
| Option | Short | Description |
|---|---|---|
| –template | -t | Word template file path (.docx) |
| –data | -d | JSON data file path or JSON string |
| –output | -o | Output file path |
| –extract-placeholders | -e | Extract placeholder keys from template (no generation) |
Project Structure
1 | skill/ |
Debugging
When document generation fails, use the placeholder extraction feature to debug:
1 | import { extractPlaceholders } from './scripts/generate.js'; |
Upgrade to Full Version
This is a simplified free version. For complete features, upgrade to the full Sheet-to-Doc:
- Batch document generation (each row generates an independent document)
- Multiple data sources: Excel, CSV, JSONL support
- Image insertion:
{image|_inline_image} - QR code generation:
{url|_qrcode} - Conditional logic:
{field==value} - Loop processing:
{#data}{/data} - Document encryption
- Remove footer attribution
License
MIT License
Support
- Official Website: https://sheet-to-doc.wtsolutions.cn
- Documentation: https://sheet-to-doc.wtsolutions.cn/en/latest/index.html
- Contact: [email protected]