name: spreadsheet-generator description: 使用Claude和Anthropic的xlsx技能生成具有数据、图表和专业格式化的Excel电子表格 version: 1.0.0 author: VTCode Team
电子表格生成器技能
生成具有结构化数据、公式、图表和专业格式化的Excel电子表格。这个技能利用Anthropic的xlsx代理技能以编程方式创建Excel文档。
指令
** 重要:vtcode兼容性说明 **
这个技能需要Anthropic的容器技能功能(xlsx技能),仅通过以下方式可用:
- Anthropic的官方CLI(
anthropic命令) - 启用技能的Claude Desktop应用
- 直接Anthropic API,使用
container.skills参数
vtcode目前不支持Anthropic容器技能。 相反,使用以下方法之一:
选项1:使用Anthropic CLI(推荐)
# 安装Anthropic CLI:pip install anthropic
# 设置API密钥:export ANTHROPIC_API_KEY=your_key
anthropic messages create \
--model claude-3-5-sonnet-20241022 \
--max-tokens 4096 \
--container-skills anthropic:xlsx:latest \
--message "Create an Excel file with [your specification]"
选项2:使用openpyxl的Python脚本
使用vtcode的execute_code工具,配合Python和openpyxl库:
import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment
from openpyxl.chart import BarChart, Reference
# 创建workbook
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Financial Dashboard"
# 添加标题
headers = ["Month", "Revenue", "Expenses", "Profit"]
ws.append(headers)
# 样式标题
for cell in ws[1]:
cell.font = Font(bold=True)
cell.fill = PatternFill(start_color="366092", fill_type="solid")
# 添加样本数据
data = [
["Q1", 150000, 90000, 60000],
["Q2", 175000, 95000, 80000],
["Q3", 200000, 100000, 100000],
["Q4", 225000, 110000, 115000]
]
for row in data:
ws.append(row)
# 保存文件
wb.save("financial_dashboard.xlsx")
print("Spreadsheet created: financial_dashboard.xlsx")
选项3:使用CSV + 手动导入
生成用户可以手动导入Excel的CSV数据:
import csv
data = [
["Month", "Revenue", "Expenses", "Profit"],
["Q1", 150000, 90000, 60000],
["Q2", 175000, 95000, 80000],
]
with open("data.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(data)
print("CSV created: data.csv (import into Excel manually)")
原始Anthropic API指令(供参考)
使用Anthropic的官方工具与容器技能时:
- 理解需求:解析数据内容、结构、格式化、图表、公式
- 计划电子表格:草图布局、识别计算、确定图表类型
- 使用Anthropic API创建:
import anthropic client = anthropic.Anthropic() response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=4096, tools=[{"type": "code_execution", "name": "bash"}], messages=[{ "role": "user", "content": "Create an Excel file with [specification]" }], container={ "type": "skills", "skills": [{"type": "anthropic", "skill_id": "xlsx", "version": "latest"}] }, betas=["code-execution-2025-08-25", "skills-2025-10-02"] ) - 提取文件引用:在响应内容块中定位file_id
示例
财务仪表板
输入:“Create a quarterly financial dashboard with revenue, expenses, and profit margins” 输出:具有多个工作表的Excel文件 - 原始数据、计算、可视化仪表板
销售分析
输入:“Generate a sales report for Q4 2024 by region with growth percentages and trend analysis” 输出:具有区域数据、指标和图表的结构化电子表格
库存跟踪
输入:“Create an inventory management spreadsheet with SKU, quantity, cost, and reorder levels” 输出:具有公式和条件格式的专业库存跟踪器
支持的功能
- 多个工作表:创建和组织跨工作表的数据
- 格式化:颜色、字体、数字格式、边框
- 公式:SUM、AVERAGE、IF、VLOOKUP和复杂计算
- 图表:条形图、折线图、饼图、散点图,带有适当标签
- 表格:格式化数据范围,带有过滤器
- 条件格式:根据值高亮单元格
- 合并单元格:专业布局,带有跨度
- 数字格式:货币、百分比、日期
使用案例
- 财务报告和分析
- 销售绩效仪表板
- 员工记录和薪资
- 库存和资产管理
- 预算规划和跟踪
- 数据分析和摘要
- 项目时间线和日程
- 调查结果汇编
最佳实践
- 清晰结构:使用标题并逻辑组织数据
- 公式优于静态数据:使用计算以提高可维护性
- 专业格式化:匹配公司标准和品牌
- 文档:包括注释或指令工作表
- 图表选择:使用适合数据类型的可视化
- 性能:优化大数据集与摘要
相关技能
doc-generator- 用于书面报告和文档pdf-report-generator- 用于最终分发就绪的报告presentation-builder- 用于利益相关者演示
限制
- 最大文件大小:代码执行环境约50MB
- 不支持复杂VBA宏
- 实时数据连接限制
- 高级Power Query工作流需要在生成后手动设置