xlsx-generator by jwynia/agent-skills
npx skills add https://github.com/jwynia/agent-skills --skill xlsx-generator在以下情况下使用此技能:
{{TITLE}} 或 ${date}在以下情况下请勿使用此技能:
{{PLACEHOLDERS}}广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
提取单元格清单以了解可替换的内容:
deno run --allow-read scripts/analyze-template.ts financial-template.xlsx > inventory.json
输出 (inventory.json):
{
"filename": "financial-template.xlsx",
"sheetCount": 3,
"sheets": [
{
"name": "Summary",
"rowCount": 25,
"colCount": 8,
"usedRange": "A1:H25",
"cells": [
{ "address": "A1", "row": 1, "col": 1, "value": "{{REPORT_TITLE}}", "type": "string" },
{ "address": "B3", "row": 3, "col": 2, "value": "{{DATE}}", "type": "string" },
{ "address": "C5", "row": 5, "col": 3, "value": null, "type": "number", "formula": "SUM(C6:C20)" }
]
}
],
"placeholders": [
{ "tag": "{{REPORT_TITLE}}", "location": "Summary!A1", "sheet": "Summary", "address": "A1" },
{ "tag": "{{DATE}}", "location": "Summary!B3", "sheet": "Summary", "address": "B3" }
],
"hasFormulas": true
}
创建 replacements.json:
{
"textReplacements": [
{ "tag": "{{REPORT_TITLE}}", "value": "Q4 2024 Financial Report" },
{ "tag": "{{DATE}}", "value": "December 15, 2024" },
{ "tag": "{{COMPANY}}", "value": "Acme Corporation", "sheets": ["Summary", "Cover"] }
],
"cellUpdates": [
{ "sheet": "Data", "address": "B5", "value": 1250000 },
{ "sheet": "Data", "address": "B6", "value": 750000 }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
financial-template.xlsx replacements.json output.xlsx
创建 spec.json:
{
"title": "Sales Report",
"author": "Finance Team",
"sheets": [
{
"name": "Sales Data",
"data": [
["Product", "Q1", "Q2", "Q3", "Q4", "Total"],
["Widget A", 10000, 12000, 15000, 18000, null],
["Widget B", 8000, 9000, 11000, 13000, null],
["Widget C", 5000, 6000, 7000, 8000, null]
],
"cells": [
{ "address": "F2", "formula": "SUM(B2:E2)" },
{ "address": "F3", "formula": "SUM(B3:E3)" },
{ "address": "F4", "formula": "SUM(B4:E4)" }
],
"columns": [
{ "col": "A", "width": 15 },
{ "col": "B", "width": 10 },
{ "col": "C", "width": 10 },
{ "col": "D", "width": 10 },
{ "col": "E", "width": 10 },
{ "col": "F", "width": 12 }
],
"freezePane": "A2",
"autoFilter": "A1:F4"
}
]
}
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.xlsx
场景:从模板生成月度销售报告。
步骤:
# 1. 分析模板以查找可替换内容
deno run --allow-read scripts/analyze-template.ts sales-template.xlsx --pretty
# 2. 使用月度数据创建 replacements.json
# 3. 生成报告
deno run --allow-read --allow-write scripts/generate-from-template.ts \
sales-template.xlsx replacements.json November-Sales.xlsx
场景:创建一个包含计算总计的电子表格。
spec.json:
{
"sheets": [{
"name": "Expenses",
"data": [
["Category", "January", "February", "March", "Total"],
["Office", 1500, 1600, 1400, null],
["Travel", 3000, 2500, 4000, null],
["Software", 500, 500, 500, null],
["Total", null, null, null, null]
],
"cells": [
{ "address": "E2", "formula": "SUM(B2:D2)" },
{ "address": "E3", "formula": "SUM(B3:D3)" },
{ "address": "E4", "formula": "SUM(B4:D4)" },
{ "address": "B5", "formula": "SUM(B2:B4)" },
{ "address": "C5", "formula": "SUM(C2:C4)" },
{ "address": "D5", "formula": "SUM(D2:D4)" },
{ "address": "E5", "formula": "SUM(E2:E4)" }
]
}]
}
场景:创建包含摘要和详细信息工作表的工作簿。
spec.json:
{
"title": "Q4 Report",
"sheets": [
{
"name": "Summary",
"data": [
["Department", "Budget", "Actual", "Variance"],
["Sales", 500000, 520000, null],
["Marketing", 200000, 195000, null]
],
"cells": [
{ "address": "D2", "formula": "C2-B2" },
{ "address": "D3", "formula": "C3-B3" }
]
},
{
"name": "Sales Detail",
"data": [
["Month", "Revenue", "Cost", "Profit"],
["October", 180000, 120000, null],
["November", 170000, 115000, null],
["December", 170000, 110000, null]
],
"cells": [
{ "address": "D2", "formula": "B2-C2" },
{ "address": "D3", "formula": "B3-C3" },
{ "address": "D4", "formula": "B4-C4" }
]
}
]
}
| 脚本 | 用途 | 所需权限 |
|---|---|---|
analyze-template.ts | 从 XLSX 文件中提取单元格、公式、占位符 | --allow-read |
generate-from-template.ts | 替换模板中的占位符 | --allow-read --allow-write |
generate-scratch.ts | 根据 JSON 规范创建 XLSX 文件 | --allow-read --allow-write |
| 属性 | 类型 | 描述 |
|---|---|---|
name | string | 工作表名称 |
data | array | 从 A1 开始的单元格值的二维数组 |
cells | array | 单个单元格规范 |
rows | array | 基于行的数据规范 |
columns | array | 列宽和可见性设置 |
merges | array | 合并的单元格范围 |
freezePane | string | 在此单元格处冻结窗格(例如,"A2") |
autoFilter | string | 自动筛选范围(例如,"A1:F10") |
| 属性 | 类型 | 描述 |
|---|---|---|
address | string | 单元格地址(例如,"A1"、"B2") |
value | mixed | 单元格值(字符串、数字、布尔值、null) |
formula | string | 公式,不带 = 号 |
format | string | 数字格式(例如,"#,##0.00") |
type | string | 强制类型:"string"、"number"、"boolean"、"date" |
| 属性 | 类型 | 描述 |
|---|---|---|
col | string | 列字母(例如,"A"、"B"、"AA") |
width | number | 列宽(以字符数为单位) |
hidden | boolean | 隐藏列 |
| 属性 | 类型 | 描述 |
|---|---|---|
tag | string | 要查找的占位符(例如,"{{TITLE}}") |
value | mixed | 替换值 |
sheets | array | 限制在特定工作表 |
range | string | 限制在单元格范围(例如,"A1:D10") |
症状:输出的 XLSX 文件仍包含 {{PLACEHOLDER}} 标签。
解决方案:
analyze-template.ts 以验证确切的标签文本和位置症状:公式显示为文本而不是计算结果。
解决方案:
症状:数字带有绿色三角形,表示存储为文本。
解决方案:
症状:尽管有规范,但列仍为默认宽度。
解决方案:
每周安装次数
153
代码仓库
GitHub 星标数
38
首次出现
Jan 20, 2026
安全审计
安装于
opencode129
gemini-cli121
codex120
github-copilot117
cursor113
amp102
Use this skill when:
{{TITLE}} or ${date} in cellsDo NOT use this skill when:
Template Mode : Modify existing branded templates
{{PLACEHOLDERS}} with actual valuesScratch Mode : Create spreadsheets from nothing using JSON specifications
Extract cell inventory to understand what can be replaced:
deno run --allow-read scripts/analyze-template.ts financial-template.xlsx > inventory.json
Output (inventory.json):
{
"filename": "financial-template.xlsx",
"sheetCount": 3,
"sheets": [
{
"name": "Summary",
"rowCount": 25,
"colCount": 8,
"usedRange": "A1:H25",
"cells": [
{ "address": "A1", "row": 1, "col": 1, "value": "{{REPORT_TITLE}}", "type": "string" },
{ "address": "B3", "row": 3, "col": 2, "value": "{{DATE}}", "type": "string" },
{ "address": "C5", "row": 5, "col": 3, "value": null, "type": "number", "formula": "SUM(C6:C20)" }
]
}
],
"placeholders": [
{ "tag": "{{REPORT_TITLE}}", "location": "Summary!A1", "sheet": "Summary", "address": "A1" },
{ "tag": "{{DATE}}", "location": "Summary!B3", "sheet": "Summary", "address": "B3" }
],
"hasFormulas": true
}
Create replacements.json:
{
"textReplacements": [
{ "tag": "{{REPORT_TITLE}}", "value": "Q4 2024 Financial Report" },
{ "tag": "{{DATE}}", "value": "December 15, 2024" },
{ "tag": "{{COMPANY}}", "value": "Acme Corporation", "sheets": ["Summary", "Cover"] }
],
"cellUpdates": [
{ "sheet": "Data", "address": "B5", "value": 1250000 },
{ "sheet": "Data", "address": "B6", "value": 750000 }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
financial-template.xlsx replacements.json output.xlsx
Create spec.json:
{
"title": "Sales Report",
"author": "Finance Team",
"sheets": [
{
"name": "Sales Data",
"data": [
["Product", "Q1", "Q2", "Q3", "Q4", "Total"],
["Widget A", 10000, 12000, 15000, 18000, null],
["Widget B", 8000, 9000, 11000, 13000, null],
["Widget C", 5000, 6000, 7000, 8000, null]
],
"cells": [
{ "address": "F2", "formula": "SUM(B2:E2)" },
{ "address": "F3", "formula": "SUM(B3:E3)" },
{ "address": "F4", "formula": "SUM(B4:E4)" }
],
"columns": [
{ "col": "A", "width": 15 },
{ "col": "B", "width": 10 },
{ "col": "C", "width": 10 },
{ "col": "D", "width": 10 },
{ "col": "E", "width": 10 },
{ "col": "F", "width": 12 }
],
"freezePane": "A2",
"autoFilter": "A1:F4"
}
]
}
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.xlsx
Scenario : Generate a monthly sales report from template.
Steps :
# 1. Analyze template for replaceable content
deno run --allow-read scripts/analyze-template.ts sales-template.xlsx --pretty
# 2. Create replacements.json with monthly data
# 3. Generate report
deno run --allow-read --allow-write scripts/generate-from-template.ts \
sales-template.xlsx replacements.json November-Sales.xlsx
Scenario : Create a spreadsheet with calculated totals.
spec.json :
{
"sheets": [{
"name": "Expenses",
"data": [
["Category", "January", "February", "March", "Total"],
["Office", 1500, 1600, 1400, null],
["Travel", 3000, 2500, 4000, null],
["Software", 500, 500, 500, null],
["Total", null, null, null, null]
],
"cells": [
{ "address": "E2", "formula": "SUM(B2:D2)" },
{ "address": "E3", "formula": "SUM(B3:D3)" },
{ "address": "E4", "formula": "SUM(B4:D4)" },
{ "address": "B5", "formula": "SUM(B2:B4)" },
{ "address": "C5", "formula": "SUM(C2:C4)" },
{ "address": "D5", "formula": "SUM(D2:D4)" },
{ "address": "E5", "formula": "SUM(E2:E4)" }
]
}]
}
Scenario : Create a workbook with summary and detail sheets.
spec.json :
{
"title": "Q4 Report",
"sheets": [
{
"name": "Summary",
"data": [
["Department", "Budget", "Actual", "Variance"],
["Sales", 500000, 520000, null],
["Marketing", 200000, 195000, null]
],
"cells": [
{ "address": "D2", "formula": "C2-B2" },
{ "address": "D3", "formula": "C3-B3" }
]
},
{
"name": "Sales Detail",
"data": [
["Month", "Revenue", "Cost", "Profit"],
["October", 180000, 120000, null],
["November", 170000, 115000, null],
["December", 170000, 110000, null]
],
"cells": [
{ "address": "D2", "formula": "B2-C2" },
{ "address": "D3", "formula": "B3-C3" },
{ "address": "D4", "formula": "B4-C4" }
]
}
]
}
| Script | Purpose | Permissions |
|---|---|---|
analyze-template.ts | Extract cells, formulas, placeholders from XLSX | --allow-read |
generate-from-template.ts | Replace placeholders in templates | --allow-read --allow-write |
generate-scratch.ts | Create XLSX from JSON specification | --allow-read --allow-write |
| Property | Type | Description |
|---|---|---|
name | string | Sheet name |
data | array | 2D array of cell values starting at A1 |
cells | array | Individual cell specifications |
rows | array | Row-based data specifications |
columns | array | Column width and visibility settings |
| Property | Type | Description |
|---|---|---|
address | string | Cell address (e.g., "A1", "B2") |
value | mixed | Cell value (string, number, boolean, null) |
formula | string | Formula without = sign |
format | string | Number format (e.g., "#,##0.00") |
type | string | Force type: "string", "number", "boolean", "date" |
| Property | Type | Description |
|---|---|---|
col | string | Column letter (e.g., "A", "B", "AA") |
width | number | Column width in characters |
hidden | boolean | Hide column |
| Property | Type | Description |
|---|---|---|
tag | string | Placeholder to find (e.g., "{{TITLE}}") |
value | mixed | Replacement value |
sheets | array | Limit to specific sheets |
range | string | Limit to cell range (e.g., "A1:D10") |
Symptoms : Output XLSX still contains {{PLACEHOLDER}} tags.
Solution :
analyze-template.ts to verify exact tag text and locationSymptoms : Formulas display as text instead of calculating.
Solution :
Symptoms : Numbers have green triangle indicating text storage.
Solution :
Symptoms : Columns have default width despite specification.
Solution :
Weekly Installs
153
Repository
GitHub Stars
38
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
opencode129
gemini-cli121
codex120
github-copilot117
cursor113
amp102
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
33,600 周安装
merges | array | Merged cell ranges |
freezePane | string | Freeze panes at this cell (e.g., "A2") |
autoFilter | string | Auto-filter range (e.g., "A1:F10") |