Office AutomationFreev1.1.0
npx skills add lovstudio/fill-form-skilllovstudio:fill-form
Fill Word document form templates (.docx) with structured data. Auto-detects table-based form fields (label โ value cell pairs), supports CJK/Latin mixed text with proper font switching, merged cells, and paragraph-based forms.
Part of lovstudio/skills โ by lovstudio.ai
Install
npx skills add lovstudio/skills --skill lovstudio:fill-form
Requires: Python 3.8+ and pip install python-docx
How It Works
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Template (.docx) โ
โ โโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ โ
โ โ ไธป่ฎฒไบบ โ โ ่็งฐ โ โ โ
โ โโโโโโโโโโโโผโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโค โ
โ โ ๅไฝ โ โ โ
โ โโโโโโโโโโโโผโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโค โ
โ โ ่ฎฒๅบง้ข็ฎ โ โ ๆถ้ด โ โ โ
โ โโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ --scan โ detect fields
โ --data โ fill values
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Filled (.docx) โ
โ โโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ โ
โ โ ไธป่ฎฒไบบ โ ๅผ ไธ โ ่็งฐ โ ๆๆ โ โ
โ โโโโโโโโโโโโผโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโค โ
โ โ ๅไฝ โ ๅไบฌๅคงๅญฆ โ โ
โ โโโโโโโโโโโโผโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโค โ
โ โ ่ฎฒๅบง้ข็ฎ โ AIไธๆชๆฅ โ ๆถ้ด โ 4ๆ10ๆฅ โ โ
โ โโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Usage
Step 1 โ Scan the template to see all detected fields:
python fill_form.py --template form.docx --scan
Output:
Detected 6 form fields:
1. ไธป่ฎฒไบบ
2. ่็งฐ
3. ๅไฝ
4. ่ฎฒๅบง้ข็ฎ
5. ๆถ้ด
6. ๅฐ็น
--- JSON ---
{
"ไธป่ฎฒไบบ": "",
"่็งฐ": "",
...
}
Step 2 โ Fill with a JSON data file or inline JSON:
# From JSON file
python fill_form.py --template form.docx --data-file data.json
# Inline JSON
python fill_form.py --template form.docx \
--data '{"ไธป่ฎฒไบบ": "ๅผ ไธ", "่็งฐ": "ๆๆ", "ๅไฝ": "ๅไบฌๅคงๅญฆ"}'
Output saves to the same directory as the template (form_filled.docx).
Options
| Option | Default | Description |
|---|---|---|
--template | (required) | Path to template .doc/.docx |
--output | <name>_filled.docx | Output path (defaults to template directory) |
--scan | List all detected form fields | |
--data | JSON string with field โ value mapping | |
--data-file | Path to JSON file with field โ value mapping | |
--font | Platform CJK serif | Font for filled text |
--font-size | 11 | Font size in points |
Field Detection
The script detects fillable fields in three ways:
| Method | How it works | Example |
|---|---|---|
| Table cells | Label in one cell, blank value in adjacent cell | โ ๅงๅ โ ___ โ |
| Merged rows | Full-width cell with Label๏ผ pattern | โ ๅคๆณจ๏ผ________________ โ |
| Paragraphs | Fallback for docs without tables | ๅงๅ๏ผ followed by blank line |
Fields are matched by normalized label (whitespace-insensitive), so ไธป ่ฎฒ ไบบ matches ไธป่ฎฒไบบ.
Supported Formats
| Format | Support |
|---|---|
.docx | Full support (recommended) |
.doc | Auto-converts via textutil (macOS) or LibreOffice. Table structure may be lost โ convert to .docx first for best results. |
License
MIT
formfilltemplatedocxwordtablecjk