← 返回
未分类

byteplan-word

根据已有的分析数据(analysisPlan.json + analysis_report.md)生成 Word 报告。需要先使用 byteplan-analysis skill 完成数据分析。
user_801e2aaa
未分类 community v1.0.0 2 版本 100000 Key: 无需
★ 0
Stars
📥 143
下载
💾 1
安装
2
版本
#latest

概述

BytePlan Word 报告 Skill

概述

此 Skill 根据已有的分析数据生成 Word 报告:

  1. 检查数据 - 确认 analysisPlan.json 和 analysis_report.md 存在
  2. 组装数据 - 将分析数据转换为 Word 格式
  3. 生成 Word - 使用 docx 库创建 Word 文档

前置条件:必须先使用 byteplan-analysis skill 完成数据分析。

技术栈

使用 Node.js + docx 库,与项目其他 skill 保持一致:

  • docx - Word 文档生成库

核心流程

用户输入"生成 Word"
       ↓
   检查分析数据是否存在
       ↓
   读取 analysisPlan.json
       ↓
   读取 analysis_report.md
       ↓
   组装报告数据
       ↓
   pnpm run generate
       ↓
   完成

前置条件

安装依赖

cd skills/byteplan-word
pnpm install

检查分析数据

import { existsSync, readFileSync } from 'fs';

// 检查必要文件
if (!existsSync('analysisPlan.json')) {
  throw new Error('缺少分析计划文件 analysisPlan.json,请先使用 /byteplan-analysis');
}

if (!existsSync('analysis_report.md')) {
  throw new Error('缺少分析报告文件 analysis_report.md,请先使用 /byteplan-analysis');
}

console.log('✅ 分析数据检查通过');

工作流程

步骤 1:读取分析计划

const plan = JSON.parse(readFileSync('analysisPlan.json', 'utf-8'));

console.log(`计划名称: ${plan.planName}`);
console.log(`任务数量: ${plan.tasks.length}`);

步骤 2:读取分析报告

const reportMd = readFileSync('analysis_report.md', 'utf-8');

// 解析 Markdown 中的表格数据
const parsedData = parseMarkdownReport(reportMd);

步骤 3:组装 Word 数据

根据分析计划中的任务,组装 Word 支持的数据格式:

const wordData = {
  title: plan.planName,
  subtitle: plan.planDescription,
  period: new Date().toLocaleDateString('zh-CN'),
  sections: plan.tasks.map(t => t.taskName),
  summary: extractSummary(parsedData),
  kpis: extractKPIs(parsedData),
  tables: extractTables(parsedData),
  insights: extractInsights(parsedData),
  recommendations: extractRecommendations(parsedData),
  source: 'BytePlan 数据平台'
};

步骤 4:生成 Word

cd skills/byteplan-word
pnpm run generate -- -o analysis_report.docx -d word_data.json

Word 数据格式

{
  "title": "报告标题",
  "subtitle": "副标题",
  "period": "2026年3月",
  "sections": ["一、核心指标概览", "二、数据分布分析"],
  "summary": ["摘要1", "摘要2"],
  "kpis": [
    { "label": "指标名称", "value": "数值", "unit": "单位" }
  ],
  "barChart": {
    "title": "图表标题",
    "data": [
      { "name": "类别A", "value": 100 },
      { "name": "类别B", "value": 80 }
    ]
  },
  "ratioData": {
    "title": "占比标题",
    "data": [
      { "name": "类别A", "value": 35 },
      { "name": "类别B", "value": 28 }
    ]
  },
  "rankingData": {
    "title": "排行标题",
    "data": [
      { "name": "项目A", "value": 100 },
      { "name": "项目B", "value": 85 }
    ],
    "maxItems": 10
  },
  "tableData": {
    "title": "明细表",
    "columns": [
      { "key": "字段1", "label": "显示名" }
    ],
    "rows": [
      { "字段1": "值1", "字段2": "值2" }
    ],
    "maxRows": 20
  },
  "insights": [
    { "title": "关键发现", "content": "内容" }
  ],
  "recommendations": [
    { "title": "建议", "content": "内容" }
  ],
  "appendix": {
    "说明": "补充内容"
  },
  "source": "BytePlan 数据平台"
}

Word 文档结构

章节内容说明
-----------------
1封面报告标题、副标题、数据周期
2目录报告结构概览
3执行摘要核心发现汇总
4核心指标关键数据表格
5数据分布柱状图数据
6占比分析进度条形式
7排行分析排名列表
8数据明细数据表格
9洞察发现关键洞察
10总结建议结论和建议
11附录补充数据(可选)
12结尾页报告结束

完整示例

1. 检查数据文件

if (!existsSync('analysisPlan.json') || !existsSync('analysis_report.md')) {
  console.log('请先使用 /byteplan-analysis 完成数据分析');
  return;
}

2. 读取并组装数据

const plan = JSON.parse(readFileSync('analysisPlan.json', 'utf-8'));
const report = readFileSync('analysis_report.md', 'utf-8');

// 从 Markdown 中提取数据
const data = extractDataFromMarkdown(report);

// 组装 Word 数据
const wordData = {
  title: plan.planName,
  subtitle: `分析主题: ${plan.planDescription}`,
  period: new Date().toLocaleDateString('zh-CN'),
  kpis: extractKPIs(data),
  tables: extractTables(data),
  insights: extractInsights(data),
  // ...
};

writeFileSync('word_data.json', JSON.stringify(wordData, null, 2));

3. 生成 Word

cd skills/byteplan-word
pnpm run generate -- -o analysis_report.docx -d ../word_data.json

注意事项

  • 前置条件:必须先使用 /byteplan-analysis 完成数据分析
  • 数据文件:确保 analysisPlan.jsonanalysis_report.md 存在
  • 数据转换:自动从 Markdown 中提取表格和关键数据
  • 包管理器:使用 pnpm 安装依赖

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-01 17:50 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 399 📥 149,710
office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 937 📥 187,716
office-efficiency

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 475 📥 157,511