suntianchong

Data Report Generator — CSV/Excel to Word/PDF with Charts

数据分析v1.0.0
作者:suntianchong更新于 2026-05-11data-report-generator@clawhub_suntianchong/data-report-generator
数据可视化报表生成数据洞察#CSV#Marketing#Data Analysis#Spreadsheet#PDF

据 AlphaMoat 统计,截至 2026-09,Data Report Generator — CSV/Excel to Word/PDF with Charts 累计下载 1,912 次、获 1 个星标,在全部 5,078 个 AI 技能中排名第 4,483 位,在「数据分析」分类(399 个)中排名第 349 位。

累计安装
128
累计下载
1,912
星标
1
全站排名
#4,483
全站前 89% · 「数据分析」前 88%
平台累计安装累计下载星标评论
ClawHub ↗491,8461-
SkillHub ↗1281,9121—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

该技能读取表格数据,生成图表、统计摘要和洞察,并可输出为 Word 或 PDF。分析结果可能包含源表中的个人、业务或其他敏感信息;分享前应核对输入与报告内容,并只保存到获准位置。安装 Python 包或系统字体可能改变共享机器环境,建议在隔离虚拟环境或容器中运行,避免系统级安装。

资料发布于 2026-10-29

可以用来做什么

  • 将销售或运营表格整理为分析报告
  • 根据表格生成可视化图表和摘要
  • 输出可审阅的 Word 或 PDF 文件

什么时候用

  • 用户提供 CSV 或 Excel 并要求分析或报告时
  • 表格内容适合由该运行环境处理时
  • 输出文件可检查并保存到受控位置时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

请分析这份指定表格,生成图表和 Word 报告;先说明将读取哪些工作表、输出到哪里,并标记可能包含敏感数据的内容。

月度数据趋势

累计下载1,912
4121,2182,0232026-03 · 累计下载 5232026-05 · 累计下载 1,0422026-07 · 累计下载 1,4922026-08 · 累计下载 1,6752026-09 · 累计下载 1,91226-0326-09
星标1
0122026-03 · 星标 12026-05 · 星标 12026-07 · 星标 12026-08 · 星标 12026-09 · 星标 126-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。 该技能有同名的其他版本,调整前的数据归属当前下载量最大的这一个。

月份累计下载环比星标
2026-091,912—1
2026-081,675+12.3%1
2026-071,492—1
2026-051,042—1
2026-03523—1

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

12 KB · ClawHub v1.0.0
---
name: data-report-generator
description: |
  Automatically analyze CSV or Excel files and generate professional data analysis reports with charts, 
  summaries, and insights — output as Word (.docx) or PDF. Use this skill whenever the user uploads or 
  mentions a data file (CSV, Excel, .xlsx, .xls) and wants a report, analysis, summary, dashboard, or 
  visualization of that data. Also trigger when users say things like "analyze my data", "make a report 
  from this spreadsheet", "visualize this CSV", "generate charts from my sales data", "weekly/monthly 
  report", "data summary", "turn this into a report", or ask for any kind of automated reporting from 
  tabular data. Ideal for operations, sales, marketing, and finance teams.
展开全部(共 361 行)
version: 1.0.0
metadata:
  openclaw:
    emoji: "📊"
    requires:
      bins:
        - python3
        - pip
---

# Data Report Generator

Transform raw CSV or Excel files into professional, insight-rich reports with charts — output as Word (.docx) or PDF.

## When This Skill Activates

Trigger when user provides:
- A CSV, Excel (.xlsx/.xls), or TSV file + asks for a report/analysis
- A request to "visualize", "summarize", or "analyze" tabular data
- Any mention of automated weekly/monthly reporting

If no file is uploaded yet, ask the user to upload their data file first.

---

## Step 1: Gather Inputs

Ask for (or infer from context):
1. **Data file** — CSV, Excel, TSV (required)
2. **Report format** — Word (.docx) or PDF? (default: Word)
3. **Report purpose** — sales analysis? operations? marketing? financial? (affects framing)
4. **Key questions** — what does the user most want to understand from this data?
5. **Audience** — internal team? executive summary? client-facing?
6. **Language** — Chinese or English? (default: match user's language)

If purpose/questions aren't specified, proceed with a comprehensive general analysis.

---

## Step 2: Read and Profile the Data

```python
import pandas as pd
import numpy as np

# Support both CSV and Excel
def load_data(filepath):
    ext = filepath.rsplit('.', 1)[-1].lower()
    if ext in ['xlsx', 'xls']:
        df = pd.read_excel(filepath)
    elif ext == 'csv':
        # Try common encodings
        for enc in ['utf-8', 'gbk', 'gb2312', 'utf-8-sig']:
            try:
                df = pd.read_csv(filepath, encoding=enc)
                break
            except:
                continue
    elif ext == 'tsv':
        df = pd.read_csv(filepath, sep='\t')
    return df

df = load_data('/path/to/file')
```

### Data Profile to Extract

- Shape: row count, column count
- Column types: numeric, categorical, date/time, text
- Missing values: count and % per column
- Basic stats: mean, median, min, max, std for numeric columns
- Unique value counts for categorical columns
- Date range if time columns exist
- Obvious data quality issues

---

## Step 3: Auto-Detect Report Type

Based on column names and data types, auto-select the analysis approach:

| Data Pattern | Report Type | Reference File |
|---|---|---|
| Date column + numeric values | **Time Series / Trend** | `references/time-series.md` |
| Category + numeric (sales/revenue) | **Sales / Performance** | `references/sales-analysis.md` |
| Multiple numeric columns | **Correlation / Distribution** | `references/statistical.md` |
| Category breakdowns only | **Segmentation** | `references/segmentation.md` |
| Mixed / unknown | **General Analysis** | `references/general.md` |

Read the relevant reference file for chart selection and narrative guidance.

If the user specifies a report type, use that. Otherwise, auto-detect.

---

## Step 4: Generate Charts

Install dependencies first:

```bash
pip install matplotlib seaborn pandas openpyxl --break-system-packages --quiet
```

### Chart Generation Rules

```python
import matplotlib
matplotlib.use('Agg')  # Non-interactive backend — ALWAYS set this
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import seaborn as sns

# Style setup — professional look
plt.style.use('seaborn-v0_8-whitegrid')
COLORS = ['#2E86AB', '#A23B72', '#F18F01', '#C73E1D', '#3B1F2B', '#44BBA4']

def save_chart(fig, filename):
    fig.savefig(filename, dpi=150, bbox_inches='tight', facecolor='white')
    plt.close(fig)
```

### Chart Selection Guide

**Time series data** → Line chart (trend) + bar chart (period comparison)
```python
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(df['date'], df['value'], color=COLORS[0], linewidth=2, marker='o', markersize=4)
ax.set_title('Trend Over Time', fontsize=14, fontweight='bold')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
plt.xticks(rotation=45)
save_chart(fig, 'chart_trend.png')
```

**Category comparison** → Horizontal bar chart (easier to read labels)
```python
fig, ax = plt.subplots(figsize=(10, 6))
df_sorted = df.sort_values('value', ascending=True)
bars = ax.barh(df_sorted['category'], df_sorted['value'], color=COLORS[0])
ax.bar_label(bars, fmt='%.1f', padding=3)
ax.set_title('Performance by Category', fontsize=14, fontweight='bold')
save_chart(fig, 'chart_category.png')
```

**Distribution** → Histogram + optional KDE
```python
fig, ax = plt.subplots(figsize=(8, 5))
ax.hist(df['value'].dropna(), bins=30, color=COLORS[0], edgecolor='white', alpha=0.8)
ax.set_title('Value Distribution', fontsize=14, fontweight='bold')
save_chart(fig, 'chart_dist.png')
```

**Composition/share** → Pie or stacked bar (prefer stacked bar for >5 categories)
```python
fig, ax = plt.subplots(figsize=(8, 6))
sizes = df['value']
labels = df['category']
wedges, texts, autotexts = ax.pie(sizes, labels=labels, autopct='%1.1f%%',
                                   colors=COLORS, startangle=90)
ax.set_title('Composition', fontsize=14, fontweight='bold')
save_chart(fig, 'chart_pie.png')
```

**Correlation** → Heatmap
```python
fig, ax = plt.subplots(figsize=(10, 8))
corr = df[numeric_cols].corr()
sns.heatmap(corr, annot=True, fmt='.2f', cmap='RdBu_r', center=0,
            ax=ax, square=True, cbar_kws={'shrink': 0.8})
ax.set_title('Correlation Matrix', fontsize=14, fontweight='bold')
save_chart(fig, 'chart_corr.png')
```

**Generate 3–6 charts total** — enough to be comprehensive, not overwhelming.

---

## Step 5: Write the Report (Word .docx)

Use the `docx` Python library. Install: `pip install python-docx --break-system-packages --quiet`

### Report Structure

```
1. Cover Page
   - Report title, data source name, date generated
2. Executive Summary (1 page)
   - 3-5 key findings in plain language
   - Most important metric highlighted
3. Data Overview
   - Dataset dimensions, time range, data quality notes
4. [Core Analysis Sections — vary by report type]
   - Each section: narrative paragraph + chart + key takeaways
5. Key Insights & Recommendations
   - Actionable bullet points
6. Appendix: Data Statistics Table
```

### Docx Code Pattern

```python
from docx import Document
from docx.shared import Inches, Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
import datetime

doc = Document()

# Page setup
section = doc.sections[0]
section.page_width = Inches(8.5)
section.page_height = Inches(11)
section.left_margin = Inches(1)
section.right_margin = Inches(1)
section.top_margin = Inches(1)
section.bottom_margin = Inches(1)

# Title style
def add_title(doc, text, level=1):
    heading = doc.add_heading(text, level=level)
    heading.alignment = WD_ALIGN_PARAGRAPH.LEFT
    run = heading.runs[0]
    run.font.color.rgb = RGBColor(0x2E, 0x86, 0xAB)  # Brand blue
    return heading

# Body text
def add_paragraph(doc, text):
    p = doc.add_paragraph(text)
    p.paragraph_format.space_after = Pt(6)
    run = p.runs[0] if p.runs else p.add_run()
    run.font.size = Pt(11)
    return p

# Insert chart image
def add_chart(doc, image_path, caption, width=6.0):
    doc.add_picture(image_path, width=Inches(width))
    last_paragraph = doc.paragraphs[-1]
    last_paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
    cap = doc.add_paragraph(caption)
    cap.alignment = WD_ALIGN_PARAGRAPH.CENTER
    cap.runs[0].font.size = Pt(9)
    cap.runs[0].font.color.rgb = RGBColor(0x66, 0x66, 0x66)

# Stats table
def add_stats_table(doc, df):
    stats = df.describe().round(2)
    table = doc.add_table(rows=len(stats)+1, cols=len(stats.columns)+1)
    table.style = 'Table Grid'
    # Header row
    table.cell(0, 0).text = 'Metric'
    for j, col in enumerate(stats.columns):
        table.cell(0, j+1).text = str(col)
    # Data rows
    for i, idx in enumerate(stats.index):
        table.cell(i+1, 0).text = str(idx)
        for j, col in enumerate(stats.columns):
            table.cell(i+1, j+1).text = str(stats.loc[idx, col])

# Save
doc.save('/home/claude/report_output.docx')
```

---

## Step 6: Convert to PDF (if requested)

```bash
# Use LibreOffice for conversion
python /path/to/skills/docx/scripts/office/soffice.py \
  --headless --convert-to pdf /home/claude/report_output.docx \
  --outdir /home/claude/
```

If LibreOffice is unavailable, fall back to `reportlab`:
```bash
pip install reportlab --break-system-packages --quiet
```
See `references/pdf-fallback.md` for reportlab-based PDF generation.

---

## Step 7: Output to User

1. Copy final file to `/mnt/user-data/outputs/`
2. Use `present_files` tool to share it
3. Include a brief summary in chat:
   - What data was analyzed
   - How many charts were generated
   - Top 3 insights found
   - Any data quality issues to be aware of

---

## Output Quality Checklist

Before delivering, verify:
- [ ] Charts have titles, axis labels, and readable fonts
- [ ] No blank/empty chart images
- [ ] Report has executive summary with plain-language findings
- [ ] Data quality issues are noted (missing values, anomalies)
- [ ] File opens cleanly (test docx structure validity)
- [ ] Chinese text renders correctly if using Chinese (use `SimHei` or `Microsoft YaHei` font in matplotlib)
- [ ] All chart image files exist before embedding in docx

---

## Handling Chinese / CJK Text in Charts

```python
import matplotlib
# Set Chinese-compatible font
matplotlib.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 
                                           'PingFang SC', 'DejaVu Sans']
matplotlib.rcParams['axes.unicode_minus'] = False  # Fix minus sign rendering
```

If font not available on system:
```bash
pip install matplotlib --break-system-packages
# Download and install a CJK font
apt-get install -y fonts-wqy-zenhei 2>/dev/null || true
```

---

## Edge Cases

**Large datasets (>100k rows)**: Sample or aggregate before visualization. Note sampling in report.

**Messy/dirty data**: Document cleaning steps in the report's "Data Overview" section. Show before/after counts.

**Single column data**: Generate distribution analysis only. Note limitation.

**All categorical data**: Focus on frequency analysis and cross-tabulations. No numeric charts.

**Date parsing issues**: Try multiple date formats (`dayfirst=True`, `yearfirst=True`, `infer_datetime_format=True`).

**Multiple sheets in Excel**: Ask user which sheet(s) to analyze, or analyze all and create multi-section report.

---

## Reference Files

- `references/time-series.md` — Trend analysis, seasonality detection, period-over-period comparisons
- `references/sales-analysis.md` — Sales/revenue specific charts, KPI calculations, funnel analysis
- `references/statistical.md` — Correlation, distribution, outlier detection, regression
- `references/segmentation.md` — Category breakdowns, cohort analysis, ranking
- `references/general.md` — General-purpose analysis for unknown data types
- `references/pdf-fallback.md` — PDF generation with reportlab when LibreOffice unavailable
- `references/chart-styling.md` — Advanced chart styling, brand colors, annotation patterns

「数据分析」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。