report-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Report Generator Skill

报告生成Skill

Overview

概述

This skill enables automatic generation of professional data reports. Create dashboards, KPI summaries, and analytical reports with charts, tables, and insights from your data.
该Skill可自动生成专业的数据报告。你可以基于数据创建仪表盘、KPI汇总和分析报告,包含图表、表格和洞察信息。

How to Use

使用方法

  1. Provide data (CSV, Excel, JSON, or describe it)
  2. Specify the type of report needed
  3. I'll generate a formatted report with visualizations
Example prompts:
  • "Generate a sales report from this data"
  • "Create a monthly KPI dashboard"
  • "Build an executive summary with charts"
  • "Produce a data analysis report"
  1. 提供数据(支持CSV、Excel、JSON格式,或直接描述数据)
  2. 指定所需的报告类型
  3. 我会生成带有可视化效果的格式化报告
示例提示词:
  • "基于这份数据生成销售报告"
  • "创建月度KPI仪表盘"
  • "生成带有图表的执行摘要"
  • "制作数据分析报告"

Domain Knowledge

领域知识

Report Components

报告组成部分

python
undefined
python
undefined

Report structure

Report structure

report = { 'title': 'Monthly Sales Report', 'period': 'January 2024', 'sections': [ 'executive_summary', 'kpi_dashboard', 'detailed_analysis', 'charts', 'recommendations' ] }
undefined
report = { 'title': 'Monthly Sales Report', 'period': 'January 2024', 'sections': [ 'executive_summary', 'kpi_dashboard', 'detailed_analysis', 'charts', 'recommendations' ] }
undefined

Using Python for Reports

使用Python生成报告

python
import pandas as pd
import matplotlib.pyplot as plt
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def generate_report(data, output_path):
    # Load data
    df = pd.read_csv(data)
    
    # Calculate KPIs
    total_revenue = df['revenue'].sum()
    avg_order = df['revenue'].mean()
    growth = df['revenue'].pct_change().mean()
    
    # Create charts
    fig, axes = plt.subplots(2, 2, figsize=(12, 10))
    df.plot(kind='bar', ax=axes[0,0], title='Revenue by Month')
    df.plot(kind='line', ax=axes[0,1], title='Trend')
    plt.savefig('charts.png')
    
    # Generate PDF
    # ... PDF generation code
    
    return output_path
python
import pandas as pd
import matplotlib.pyplot as plt
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def generate_report(data, output_path):
    # Load data
    df = pd.read_csv(data)
    
    # Calculate KPIs
    total_revenue = df['revenue'].sum()
    avg_order = df['revenue'].mean()
    growth = df['revenue'].pct_change().mean()
    
    # Create charts
    fig, axes = plt.subplots(2, 2, figsize=(12, 10))
    df.plot(kind='bar', ax=axes[0,0], title='Revenue by Month')
    df.plot(kind='line', ax=axes[0,1], title='Trend')
    plt.savefig('charts.png')
    
    # Generate PDF
    # ... PDF generation code
    
    return output_path

HTML Report Template

HTML报告模板

python
def generate_html_report(data, title):
    html = f'''
    <!DOCTYPE html>
    <html>
    <head>
        <title>{title}</title>
        <style>
            body {{ font-family: Arial; margin: 40px; }}
            .kpi {{ display: flex; gap: 20px; }}
            .kpi-card {{ background: #f5f5f5; padding: 20px; border-radius: 8px; }}
            .metric {{ font-size: 2em; font-weight: bold; color: #2563eb; }}
            table {{ border-collapse: collapse; width: 100%; }}
            th, td {{ border: 1px solid #ddd; padding: 12px; text-align: left; }}
        </style>
    </head>
    <body>
        <h1>{title}</h1>
        <div class="kpi">
            <div class="kpi-card">
                <div class="metric">${data['revenue']:,.0f}</div>
                <div>Total Revenue</div>
            </div>
            <div class="kpi-card">
                <div class="metric">{data['growth']:.1%}</div>
                <div>Growth Rate</div>
            </div>
        </div>
        <!-- More content -->
    </body>
    </html>
    '''
    return html
python
def generate_html_report(data, title):
    html = f'''
    <!DOCTYPE html>
    <html>
    <head>
        <title>{title}</title>
        <style>
            body {{ font-family: Arial; margin: 40px; }}
            .kpi {{ display: flex; gap: 20px; }}
            .kpi-card {{ background: #f5f5f5; padding: 20px; border-radius: 8px; }}
            .metric {{ font-size: 2em; font-weight: bold; color: #2563eb; }}
            table {{ border-collapse: collapse; width: 100%; }}
            th, td {{ border: 1px solid #ddd; padding: 12px; text-align: left; }}
        </style>
    </head>
    <body>
        <h1>{title}</h1>
        <div class="kpi">
            <div class="kpi-card">
                <div class="metric">${data['revenue']:,.0f}</div>
                <div>Total Revenue</div>
            </div>
            <div class="kpi-card">
                <div class="metric">{data['growth']:.1%}</div>
                <div>Growth Rate</div>
            </div>
        </div>
        <!-- More content -->
    </body>
    </html>
    '''
    return html

Example: Sales Report

示例:销售报告

python
import pandas as pd
import matplotlib.pyplot as plt

def create_sales_report(csv_path, output_path):
    # Read data
    df = pd.read_csv(csv_path)
    
    # Calculate metrics
    metrics = {
        'total_revenue': df['amount'].sum(),
        'total_orders': len(df),
        'avg_order': df['amount'].mean(),
        'top_product': df.groupby('product')['amount'].sum().idxmax()
    }
    
    # Create visualizations
    fig, axes = plt.subplots(2, 2, figsize=(14, 10))
    
    # Revenue by product
    df.groupby('product')['amount'].sum().plot(
        kind='bar', ax=axes[0,0], title='Revenue by Product'
    )
    
    # Monthly trend
    df.groupby('month')['amount'].sum().plot(
        kind='line', ax=axes[0,1], title='Monthly Revenue'
    )
    
    plt.tight_layout()
    plt.savefig(output_path.replace('.html', '_charts.png'))
    
    # Generate HTML report
    html = generate_html_report(metrics, 'Sales Report')
    
    with open(output_path, 'w') as f:
        f.write(html)
    
    return output_path

create_sales_report('sales_data.csv', 'sales_report.html')
python
import pandas as pd
import matplotlib.pyplot as plt

def create_sales_report(csv_path, output_path):
    # Read data
    df = pd.read_csv(csv_path)
    
    # Calculate metrics
    metrics = {
        'total_revenue': df['amount'].sum(),
        'total_orders': len(df),
        'avg_order': df['amount'].mean(),
        'top_product': df.groupby('product')['amount'].sum().idxmax()
    }
    
    # Create visualizations
    fig, axes = plt.subplots(2, 2, figsize=(14, 10))
    
    # Revenue by product
    df.groupby('product')['amount'].sum().plot(
        kind='bar', ax=axes[0,0], title='Revenue by Product'
    )
    
    # Monthly trend
    df.groupby('month')['amount'].sum().plot(
        kind='line', ax=axes[0,1], title='Monthly Revenue'
    )
    
    plt.tight_layout()
    plt.savefig(output_path.replace('.html', '_charts.png'))
    
    # Generate HTML report
    html = generate_html_report(metrics, 'Sales Report')
    
    with open(output_path, 'w') as f:
        f.write(html)
    
    return output_path

create_sales_report('sales_data.csv', 'sales_report.html')

Resources

资源