pivot-table-generator

Generate a pivot table from a source Excel file and add it as a new sheet: rows = product name, columns = store custom ID, values = sum of store order demand, include a total column and sort by total descending.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "pivot-table-generator" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-09b944032518d584e3773a7c8a1f1c606a844f9fdddb043e9b0640ad9a8a05be. Verify the upstream source and version against https://skillhub.cn/skills/user_8451910d/pivot-table-generator before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate a pivot table from a source Excel file and add it as a new sheet: rows = product name, columns = store custom ID, values = sum of store order demand, include a total column and sort by total descending.

0 Downloads

Introduction source: third_party · user_8451910d · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: pivot-table-generator
description: 从数据源Excel文件生成数据透视表,以新sheet页添加到原文件中。行=商品名称,列=门店自定义序号,值=求和:门店订货需求数,加总计列并按从大到小排序。
triggers:
  - 用户提供一个数据源文件(xlsx),要求做数据透视表
  - 用户说"做个透视表"、"生成透视表"、"pivot table"、"数据透视"
  - 用户在文档处理场景下给了一个文件
  - 关键词: 透视表、pivot、门店订货需求数、商品名称、门店自定义序号
agent_created: true

Pivot Table Generator

触发条件

当用户提供一个 Excel 数据源文件,并需要生成数据透视表时使用此技能。

触发关键词:透视表、pivot、门店订货需求数、商品名称、门店自定义序号、做个表、数据透视

数据透视表规则

  1. 行 (Rows): 商品名称
  2. 列 (Columns): 门店自定义序号
  3. 值 (Values): 求和项:门店订货需求数
  4. 总计列: 在商品名称后面添加一列"总计",值为该商品所有门店的订货需求数之和
  5. 排序: 按总计列从大到小排序(降序)
  6. 列合计行: 在第二行(表头下方)添加一行"合计",汇总每一列所有商品的数据之和
  7. 输出位置: 以新的 sheet 页添加到用户提供的原始数据源文件中

执行流程

Step 1: 读取数据源文件

用 openpyxl 或 pandas 读取用户提供的 xlsx 文件,获取所有数据列名,确认以下字段存在:

  • 商品名称
  • 门店自定义序号
  • 门店订货需求数

如果列名不完全匹配,检查是否存在相似列名(如"门店订货需求"等),并告知用户确认。

Step 2: 生成透视表数据

用 pandas 生成 pivot_table:

pivot = df.pivot_table(
    index='商品名称',
    columns='门店自定义序号',
    values='门店订货需求数',
    aggfunc='sum',
    fill_value=0
)

Step 3: 添加总计列并排序

pivot['总计'] = pivot.sum(axis=1)
pivot = pivot.sort_values('总计', ascending=False)

将"总计"列移到商品名称后面(即DataFrame的第二列位置)。

Step 4: 写入新 sheet 页

使用 openpyxl 将透视表数据写入原文件的新 sheet 页:

  • sheet 页名称: "数据透视表"(如果已存在则追加日期后缀避免冲突)
  • 第一行写列标题(门店自定义序号值 + "总计")
  • 第二行写"合计"行,汇总每一列所有商品的数值之和
  • 第一列写商品名称(从第三行开始)
  • 保持原文件所有内容不变,仅在末尾新增 sheet

Step 5: 格式美化

  • 表头行加粗、居中
  • 数值列右对齐
  • 添加边框线
  • 冻结首行和首列方便查看
  • 列宽自适应

注意事项

  • 不要修改原文件中的任何现有数据或 sheet 页
  • 如果某个商品在某门店没有数据,对应单元格填 0
  • 门店自定义序号列的各值作为透视表的列标题
  • 输出文件即原文件本身(不是另存为新文件)
  • 完成后告知用户透视表已添加到哪个 sheet 页

依赖

  • openpyxl
  • pandas

使用隔离的 Python 环境安装:

C:\Users\Administrator\.workbuddy\binaries\python\envs\default\Scripts\pip.exe install openpyxl pandas

运行脚本:

C:\Users\Administrator\.workbuddy\binaries\python\envs\default\Scripts\python.exe <script_path>

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决 Excel 数据透视表生成这一明确办公场景需求
  • 具有广泛受众和实用价值,属于通用工具范畴
Trigger Precision90/100

Highlights

  • 触发词覆盖合理,关键词明确,边界清晰
Structure and Standards95/100

Highlights

  • Phase/步骤清晰,有出口条件,含端到端示例
  • frontmatter 完整,单文件未超 500 行
Execution Reliability90/100

Highlights

  • 工具来源明确,参数正确,覆盖主要异常
  • 不可逆操作有明确说明,依赖安装命令完整
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.