← Back to Skills Marketplace
101
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install income-statement-cn
Description
根据明细表数据,自动生成规范格式利润表,收入支出按分类 2/3 分组动态汇总,含经营利润计算、固定格式和列宽。
README (SKILL.md)
财务报表生成技能
技能概述
根据明细表数据自动生成规范化利润表,支持动态行数扩展。
核心规则
数据提取规则
收入类:
- 来源:明细表中 分类 1 = "收入" 或 "实收"
- 取值优先级:
- 优先取"发生金额"列(列 8)
- 其次取"收入金额"列(列 6)
- 分组:按 分类 2 和 分类 3 两级分组汇总
支出类:
- 来源:明细表中 分类 1 = "支出"
- 取值优先级:
- 优先取"发生金额"列(列 8)
- 其次取"支出金额"列(列 7)
- 分组:按 分类 2 和 分类 3 两级分组汇总
利润表格式规范
列结构:
| 列 | 内容 | 宽度 |
|---|---|---|
| B | 标题(收入/支出/经营利润) | 15 |
| C | 分类 2(工作坊/个案/导师费等) | 12 |
| D | 分类 3(具体项目名称) | 40 |
| E | 金额 | 15 |
| F | 空白 | 40 |
行结构:
- 标题行:合并 B1:F1,"利润表 YYYYMM"居中,粗体
- 收入区块:
- 行 3:B3="收入"(粗体),E3=合计公式(粗体)
- 行 4+:分类 2 标题(如"工作坊"),E 列=小计
- 后续行:D 列=分类 3 明细,E 列=金额(动态行数)
- 支出区块:
- 标题行:B 列="支出"(粗体),E 列=合计(粗体)
- 分类 2 标题行(导师费/场地费等),E 列=小计
- 明细行:D 列=分类 3,E 列=金额(动态行数)
- 经营利润行:B 列="经营利润"(粗体),E 列=公式(粗体)
格式要求:
- 无边框
- "收入"、"支出"、"经营利润"文字粗体
- 三者对应金额粗体
- F 列留空,宽度与 D 列相同(40)
代码模板
#!/usr/bin/env python3
from openpyxl import load_workbook, Workbook
from openpyxl.styles import Font, Alignment
import glob
def create_income_statement(source_file, output_file):
"""
根据明细表生成利润表
Args:
source_file: 源 Excel 文件路径(含明细表)
output_file: 输出利润表路径
"""
wb_source = load_workbook(source_file)
ws_detail = wb_source['明细']
# 数据提取
income_by_cat2_cat3 = {}
expense_by_cat2_cat3 = {}
for row in range(2, ws_detail.max_row + 1):
cat1 = ws_detail.cell(row=row, column=3).value
cat2 = ws_detail.cell(row=row, column=4).value
cat3 = ws_detail.cell(row=row, column=5).value
income_amt = ws_detail.cell(row=row, column=6).value
expense_amt = ws_detail.cell(row=row, column=7).value
amount = ws_detail.cell(row=row, column=8).value
# 收入:优先发生金额
if cat1 in ['收入', '实收']:
amt = amount if amount else (income_amt if income_amt else 0)
if amt and amt > 0:
if cat2 not in income_by_cat2_cat3:
income_by_cat2_cat3[cat2] = {}
if cat3 not in income_by_cat2_cat3[cat2]:
income_by_cat2_cat3[cat2][cat3] = 0
income_by_cat2_cat3[cat2][cat3] += amt
# 支出:优先发生金额
if cat1 == '支出':
amt = amount if amount else (expense_amt if expense_amt else 0)
if amt and amt > 0:
if cat2 not in expense_by_cat2_cat3:
expense_by_cat2_cat3[cat2] = {}
if cat3 not in expense_by_cat2_cat3[cat2]:
expense_by_cat2_cat3[cat2][cat3] = 0
expense_by_cat2_cat3[cat2][cat3] += amt
# 创建工作簿
wb = Workbook()
ws = wb.active
ws.title = '利润表'
# 样式
title_font = Font(name='微软雅黑', size=12, bold=True)
bold_font = Font(name='微软雅黑', size=10, bold=True)
# === 填写数据 ===
# 标题行
ws.merge_cells('B1:F1')
ws['B1'] = '利润表 YYYYMM' # 替换实际月份
ws['B1'].font = title_font
ws['B1'].alignment = Alignment(horizontal='center', vertical='center')
# 收入部分
ws['B3'] = '收入'
ws['B3'].font = bold_font
# 动态填充收入明细...
# (按分类 2 标题 + 分类 3 明细的顺序)
# 支出部分
# (按分类 2 标题 + 分类 3 明细的顺序)
# 经营利润
# E 列 = E3 - 支出合计行
# F 列留空
for r in range(2, max_data_row + 1):
ws.cell(row=r, column=6, value='')
# 列宽
ws.column_dimensions['B'].width = 15
ws.column_dimensions['C'].width = 12
ws.column_dimensions['D'].width = 40
ws.column_dimensions['E'].width = 15
ws.column_dimensions['F'].width = 40
wb.save(output_file)
使用示例
# 生成 202601 利润表
create_income_statement(
source_file='/Users/zhengyong/.openclaw/qqbot/downloads/财务报表 202601-claw_1774271697631.xlsx',
output_file='/Users/zhengyong/.openclaw/workspace/利润表 202601_明细生成.xlsx'
)
关键要点
- 动态行数:有多少明细项目就占多少行,不固定
- 金额优先级:发生金额 > 收入/支出金额
- 分类层级:分类 2 是标题,分类 3 是明细
- 格式统一:收入/支出/经营利润粗体 + 金额粗体
- F 列预留:宽度 40,留空备用
文件位置
- 输入:
/Users/zhengyong/.openclaw/qqbot/downloads/财务报表 YYYYMM*.xlsx - 输出:
/Users/zhengyong/.openclaw/workspace/利润表 YYYYMM_明细生成.xlsx - 脚本:
/Users/zhengyong/.openclaw/workspace/create_income_YYYYMM_simple.py
创建时间:2026-03-23 最后更新:2026-03-23
Usage Guidance
This skill appears to do what it says (generate a formatted profit & loss Excel from a '明细' sheet). Before installing or running: 1) Verify openpyxl is installed in the execution environment. 2) Inspect and, if needed, change the example hardcoded file paths (/Users/zhengyong/...) to safe, project-specific paths to avoid accidental overwriting of files in that user's home. 3) Note the SKILL.md script name differs from the included file (generate_income_statement.py) — call the actual filename or rename for clarity. 4) The code has minor bugs (e.g., month extraction iterates characters and may not yield the expected month); test on non-sensitive sample data first. 5) If you need stricter safety, adapt the script to accept explicit input/output paths and avoid implicit defaults pointing at any user's home directory.
Capability Analysis
Type: OpenClaw Skill
Name: income-statement-cn
Version: 1.0.0
The skill bundle is a legitimate utility for generating financial income statements from Excel data using the openpyxl library. The code in generate_income_statement.py and the instructions in SKILL.md are strictly limited to data processing, formatting, and file I/O within the local environment. There are no indicators of network activity, shell execution, or unauthorized data access, and the hardcoded file paths appear to be specific to the developer's local setup rather than a malicious payload.
Capability Assessment
Purpose & Capability
The name/description (生成利润表) align with the provided Python implementation: it reads an Excel sheet named '明细', aggregates by 分类2/分类3, formats a new workbook, and writes an output file. The logic for income/expense selection matches the documented priority rules.
Instruction Scope
The SKILL.md and code stay within the stated purpose (reading a local Excel and writing a formatted workbook). However, the documentation uses hardcoded example paths under /Users/zhengyong/.openclaw/ and an example script path that does not match the included filename (SKILL.md suggests create_income_YYYYMM_simple.py but the repo contains generate_income_statement.py). These user-specific paths and filename mismatch are inconsistent and could cause confusion or accidental overwriting if used as-is.
Install Mechanism
There is no install spec (lowest disk risk). The code requires the openpyxl package but the skill does not declare dependencies or provide an install step; a runner would need to ensure openpyxl is available. No network downloads or external packages are pulled by the skill itself.
Credentials
The skill requests no environment variables or credentials. It does, however, read and write files under explicit user home paths in examples (~/ .openclaw/...), which is proportionate for a local report-generator but is user-specific and may unintentionally access other files if the pattern is used blindly.
Persistence & Privilege
always:false and no code attempts to modify other skills, agent settings, or persist credentials. The script writes only the output Excel file and prints a confirmation; it does not attempt network calls or background persistence.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install income-statement-cn - After installation, invoke the skill by name or use
/income-statement-cn - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
从交易记录生成标准化利润表 Excel
Metadata
Frequently Asked Questions
What is 利润表生成?
根据明细表数据,自动生成规范格式利润表,收入支出按分类 2/3 分组动态汇总,含经营利润计算、固定格式和列宽。 It is an AI Agent Skill for Claude Code / OpenClaw, with 101 downloads so far.
How do I install 利润表生成?
Run "/install income-statement-cn" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is 利润表生成 free?
Yes, 利润表生成 is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does 利润表生成 support?
利润表生成 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created 利润表生成?
It is built and maintained by zen (@courage-zen); the current version is v1.0.0.
More Skills