wps-pivot — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited wps-pivot (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
用人话解释透视表 → 帮你拖对字段 → 生成结果。
"透视表就是:按X分组,算Y的汇总。" 就这么简单。
wps-formulawps-chart透视表 = 按【行标签】分组,计算【值字段】的【汇总方式】
例子:
"按部门统计人数"
→ 行标签=部门,值=姓名,汇总=计数
"各月份各产品的销售额合计"
→ 行标签=月份,列标签=产品,值=销售额,汇总=求和
"每个销售员的平均单价"
→ 行标签=销售员,值=单价,汇总=平均值┌─────────────────────────────────────┐
│ 你的数据有哪些列? │
│ │
│ 分类列(文本)→ 拖到【行】或【列】 │
│ 如:部门、月份、产品、地区 │
│ │
│ 数值列(数字)→ 拖到【值】 │
│ 如:金额、数量、分数 │
│ │
│ 筛选列(可选)→ 拖到【筛选】 │
│ 如:年份、状态 │
└─────────────────────────────────────┘
常见搭配:
┌──────────────┬──────┬──────┬────────┐
│ 需求 │ 行 │ 列 │ 值 │
├──────────────┼──────┼──────┼────────┤
│ 各部门人数 │ 部门 │ - │ 计数 │
│ 月度销售趋势 │ 月份 │ - │ 求和 │
│ 部门×月份 │ 部门 │ 月份 │ 求和 │
│ 产品占比 │ 产品 │ - │ 求和% │
└──────────────┴──────┴──────┴────────┘确认:
from openpyxl import Workbook, load_workbook
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
from collections import defaultdict
import os
def create_pivot(data_path, row_field, value_field,
agg='sum', col_field=None, output_path=None):
"""生成透视表结果"""
wb = load_workbook(data_path)
ws = wb.active
# 读取数据
headers = [cell.value for cell in ws[1]]
row_idx = headers.index(row_field)
val_idx = headers.index(value_field)
col_idx = headers.index(col_field) if col_field else None
# 聚合
if col_field:
pivot = defaultdict(lambda: defaultdict(list))
col_values = set()
for row in ws.iter_rows(min_row=2, values_only=True):
r_key = row[row_idx]
c_key = row[col_idx]
val = float(row[val_idx] or 0)
pivot[r_key][c_key].append(val)
col_values.add(c_key)
col_values = sorted(col_values)
else:
pivot = defaultdict(list)
for row in ws.iter_rows(min_row=2, values_only=True):
r_key = row[row_idx]
val = float(row[val_idx] or 0)
pivot[r_key].append(val)
# 聚合函数
agg_funcs = {
'sum': sum,
'avg': lambda x: sum(x)/len(x) if x else 0,
'count': len,
'max': max,
'min': min,
}
func = agg_funcs.get(agg, sum)
# 写入结果
wb_out = Workbook()
ws_out = wb_out.active
ws_out.title = "透视结果"
header_fill = PatternFill('solid', fgColor='2C3E50')
header_font = Font(name='微软雅黑', size=11, bold=True, color='FFFFFF')
if col_field:
# 交叉透视
ws_out.cell(row=1, column=1, value=row_field).font = header_font
ws_out.cell(row=1, column=1).fill = header_fill
for ci, cv in enumerate(col_values, 2):
ws_out.cell(row=1, column=ci, value=cv).font = header_font
ws_out.cell(row=1, column=ci).fill = header_fill
ws_out.cell(row=1, column=len(col_values)+2, value='合计').font = header_font
ws_out.cell(row=1, column=len(col_values)+2).fill = header_fill
for ri, (rk, cols) in enumerate(sorted(pivot.items()), 2):
ws_out.cell(row=ri, column=1, value=rk)
row_total = 0
for ci, cv in enumerate(col_values, 2):
val = func(cols.get(cv, [0]))
ws_out.cell(row=ri, column=ci, value=round(val, 2))
row_total += val
ws_out.cell(row=ri, column=len(col_values)+2, value=round(row_total, 2))
else:
ws_out.cell(row=1, column=1, value=row_field).font = header_font
ws_out.cell(row=1, column=1).fill = header_fill
ws_out.cell(row=1, column=2, value=f'{value_field}({agg})').font = header_font
ws_out.cell(row=1, column=2).fill = header_fill
for ri, (rk, vals) in enumerate(sorted(pivot.items()), 2):
ws_out.cell(row=ri, column=1, value=rk)
ws_out.cell(row=ri, column=2, value=round(func(vals), 2))
if not output_path:
output_path = '透视结果.xlsx'
wb_out.save(output_path)
return os.path.abspath(output_path)WPS中创建透视表(手动操作指引):
1. 选中数据区域(含表头)
2. 菜单 → 插入 → 数据透视表
3. 选择放置位置(新工作表)
4. 在右侧面板拖放字段:
- 行区域:拖入分类字段
- 列区域:拖入交叉字段(可选)
- 值区域:拖入数值字段
- 筛选区域:拖入筛选字段(可选)
5. 点击值字段 → 值字段设置 → 选择汇总方式# 简单透视
/wps-pivot 按部门统计销售额合计,数据在sales.xlsx
# 交叉透视
/wps-pivot 各部门每个月的销售额是多少
# 不懂透视表
/wps-pivot 透视表是什么?我的数据有姓名、部门、月份、销售额,想看各部门汇总~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.