skills/monthly-report-html-generator/SKILL.md
从数据源自动生成月度运营数据 HTML 报告,支持 ECharts 图表、规则驱动结论、可折叠侧栏导航
npx skillsauth add OliverOuyang/shuhe-work-skills monthly-report-html-generatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
从 Excel/CSV/Dataphin 数据源自动生成交互式月度运营数据 HTML 报告。单一 Python 脚本读取所有数据 CSV,通过 f-string 模板直接生成完整 HTML(含 ECharts 图表 + 规则驱动结论 + 可折叠侧栏导航)。
当用户需要生成月度运营数据报告时自动激活,特别适用于:
Input/rawdata.xlsx
↓ process_data.py(数据处理,产出 23 个 CSV)
Output/*.csv
↓ generate_html.py(单脚本,f-string 模板)
HTML/月报报告_{YYYYMMDD}_{HHMM}.html(自包含,仅依赖 CDN ECharts)
核心设计决策:
get_month_col() 处理 month / date_month 双命名stacked_bar_line:堆叠柱状图 + 折线(交易额、花费)dual_line:双折线图(CPS、转化漏斗)bar_multi_line:柱状图 + 多折线(质量指标)dual_line_with_bar:柱状图 + 双折线(渠道成本)single_line:单折线(整体竞得率、转化率)multi_line_grouped:多折线分组(分Q竞得率)stacked_column_chart:堆叠柱状图(撞库数据)window.addEventListener('resize') 遍历所有图表实例_trend_word(cur, prev) 返回方向词 + 变化幅度gen_conclusion_scale() — 规模(交易额 + 花费 + 最大客群)gen_conclusion_cost() — 成本(全首借CPS + T0CPS)gen_conclusion_quality() — 质量(额度 + 过件率)gen_conclusion_channel_overview() — 渠道总览(日耗 + CPS + 额度 + 过件率)gen_conclusion_request() — 请求(请求量 + 参竞率)gen_conclusion_winrate() — 竞得率(整体 + 分Q)gen_conclusion_conversion() — 转化(曝光-授信 + CTR + CVR)gen_conclusion_jz_attack() — 精准撞库gen_conclusion_jz_conversion() — 精准转化<strong>2月XX:</strong>指标A XX元,环比上升X%;toggleSidebar() + CSS transitionmargin-left: max(260px, calc((100vw - 1200px) / 2))contenteditable="true" 支持浏览器内编辑# 读取源数据 Excel,处理并输出 CSV
import pandas as pd
raw = pd.read_excel('Input/rawdata.xlsx', sheet_name=None)
# 22+ 指标处理函数,产出 Output/*.csv
from datetime import datetime
import pandas as pd
from pathlib import Path
def build_html():
# 1. 读取所有 CSV
trade = pd.read_csv("Output/trade_by_group.csv")
# ... 23 个 CSV
# 2. 单位转换
trade_total = to_js_array(trade["总计"] / 1e8, 2) # 亿
# 3. 生成结论
concl_scale = gen_conclusion_scale(trade, spend)
# 4. f-string 模板生成 HTML
html = f'''<!DOCTYPE html>
<html><head>
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.5.0/echarts.min.js"></script>
</head><body>
<blockquote>{concl_scale}</blockquote>
<div id="chart-trade"></div>
<script>
echarts.init(document.getElementById('chart-trade')).setOption({{
xAxis: {{ data: {trade_months} }},
series: [{{ data: {trade_total}, type: 'line' }}]
}});
</script>
</body></html>'''
# 5. 写入带时间戳的文件
out = Path("HTML") / datetime.now().strftime("月报报告_%Y%m%d_%H%M.html")
out.write_text(html, encoding="utf-8")
# 对比 CSV 源数据与 HTML 内嵌数据
grep "trade_total" output.html # 检查数值
# 对比 V01 PPT 数据确保一致
diff Output/trade_by_group.csv ../V01_PPT/Output/trade_by_group.csv
症状:KeyError: 'month'
根因:spend_by_channel.csv 用 date_month,其他 CSV 用 month
修复:
def get_month_col(df):
for c in ["month", "date_month"]:
if c in df.columns:
return c
raise ValueError(f"No month column: {list(df.columns)}")
症状:抖音 CVR 全显示 0.0 根因:原始值 ~4.45e-5,×100=0.00445,round(2)=0.0 修复:
# 对极小值指标使用更高精度
dy_cvf_cvr = to_js_array(dy_cv_f["CVR"] * 100, 4) # 4位小数
症状:NameError: conv_overall_js is not defined
根因:在 f-string 中引用了未定义的函数
修复:在 f-string 之前预计算所有变量
# 预计算
tx_cvo_months_js = months_js(tx_cv_o)
# 然后在 f-string 中使用 {tx_cvo_months_js}
症状:数据标签被 chart-title 文字框挡住
根因:grid.top: 20 太小
修复:全局改为 grid.top: 45
症状:margin-left: 260px; margin-right: auto 无法居中
根因:固定左偏移 + auto 右边距只会左对齐
修复:
/* 动态居中:宽屏居中,窄屏紧贴侧栏 */
#main-content {
margin-left: max(260px, calc((100vw - 1200px) / 2));
max-width: 1200px;
}
症状:3.4 ��音转化、付��商店
根因:文件编码错误或编辑器截断中文字符
修复:逐一搜索 �� 并替换为正确中文
症状:JSON 数据显示环比 +0.1pp,但结论文本写 +0.03pp(3倍差距);21 个数据点出现 WARN
根因:_fmt_pct() 使用"智能精度"(>10% 用1位小数,≤10% 用2位小数),导致 JSON 输出精度低于结论文本精度
修复:
# 统一使用2位小数,避免 chart 数据与结论文案精度不一致
def _fmt_pct(v):
return f"{v:.2f}"
泛化规则:所有百分比/千分比/比率类数据统一使用 2 位小数输出,包括日耗、日请求量、花费等金额类数据也应提升至 2 位小数
症状:setConclusions() 的 querySelectorAll 返回空数组,所有动态结论静默失败
根因:charts.js 使用 .conclusion-content 选择器,但 HTML 中实际 class 为 .conclusion-box
修复:将 JS 选择器从 .conclusion-content 改为 .conclusion-box
泛化规则:JS/CSS 选择器修改时必须同步检查 HTML 中对应元素的 class/id 是否匹配
症状:renderTradeByChannel() 和 renderTradeChange() 引用 chart-trade-by-channel 和 chart-trade-change,但 HTML 中无对应 canvas
根因:HTML 重构时移除了 canvas 元素,但 charts.js 未同步清理
修复:从 charts.js 中移除死函数及其在 initAllCharts 中的调用
泛化规则:HTML 结构变更后必须 grep 检查 JS 中所有 getElementById / querySelector 引用是否仍然有效
生成报告后必须验证:
python generate_html.py 返回 [OK])�� 返回空)_fmt_pct 输出与结论文案精度一致)getElementById/querySelector 引用在 HTML 中存在)V04_HTMl/
├── generate_html.py # 单脚本生成器(~1500行)
├── Input/
│ └── rawdata.xlsx # 源数据
├── Output/
│ ├── trade_by_group.csv # 23 个中间 CSV
│ ├── spend_by_channel.csv
│ └── ...
└── HTML/
└── 月报报告_{YYYYMMDD}_{HHMM}.html # 自包含输出
/html-report-framework - HTML 报告通用框架/dp-explorer - Dataphin 数据探索/document-skills:xlsx - Excel 数据处理tools
SQL 分段验证、自我修复、结果导出与智能分析。流程:解析SQL → Dataphin MCP 验证元数据 → 自动修复 → 分段执行验证 → 导出 CSV → 智能分析(漏斗解读、异常识别、预判用户问题)。适用场景:"跑一下这个SQL"、"验证这个查询"、"帮我执行并导出"、"分析一下结果"等。
testing
Security-first vetting for OpenClaw skills. Use before installing any skill from ClawHub, GitHub, or other sources. Checks for red flags, permission scope, and suspicious patterns.
development
A universal self-improving agent that learns from ALL skill experiences. Uses multi-memory architecture (semantic + episodic + working) to continuously evolve the codebase. Auto-triggers on skill completion/error with hooks-based self-correction.
data-ai
Standardize Jupyter notebooks (.ipynb) for interactive data analysis workflows. Enforces a mandatory cell manifest (M1-M8 + archetype chapters) with tags ([CONFIG]/[SETUP]/[FUNC]/[RUN]/[VIZ]/[EXPORT]), structured markdown sections, and output prefixes ([OK]/[WARN]/[SKIP]). Use when the user wants to standardize, clean up, or create a notebook from scratch. Two archetypes: problem-driven (question-answer analysis) and monitoring (dimension-based periodic reporting).