Install
$ agentstack add skill-yuyy2004-excel-skills-excel-insert ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
> This skill follows [[excel-safe-workflow]] four-step method. Must complete Requirement Parsing→Scout→Plan before execution, and Verify after. > 本技能遵循 [[excel-safe-workflow]] 四步法。执行前必须完成 需求解析→勘察→规划,执行后必须验证。
Excel Safe Insert (Row & Column) / Excel 安全插入(行列通用)
第零步:需求解析
自动识别插入类型 / Auto-detect Insert Type
从用户原话中判断要插入列还是行:
| 用户说 | 判定 | |--------|:--:| | "插入列""加一列""新增列""左边""右边""E列后面" | → 列模式 | | "插入行""加一行""新增行""上面""下面""第5行后面" | → 行模式 |
列模式解析
| 要素 | 常见表述 | 默认值 | |------|---------|--------| | 目标位置 | "第5列左边""E列右侧""申请日后面" | 必须明确 | | 插入方向 | "左边""左侧""前面" → left;"右边""右侧""后面" → right | left | | 表头命名 | "叫xxx" → 指定 | "新列" 或留空 | | 填充内容 | "填xxx" → 值/公式 | 空 |
行模式解析
| 要素 | 常见表述 | 默认值 | |------|---------|--------| | 目标位置 | "第5行上面""第3行下面" | 必须明确 | | 插入方向 | "上面""上方""前面" → above;"下面""下方""后面" → below | above | | 填充内容 | "填xxx" → 值/公式 | 空(留白行) |
解析示例
| 用户说 | 提取 | |--------|------| | "在E列左边插入一列,叫'格式化日期'" | 列模式, E列, left, 表头='格式化日期' | | "第5行下面加三行空行" | 行模式, 第5行, below, 3行, 空 | | "申请日后面加一列" | 列模式, 申请日(勘察定位), right |
第一步:勘察
import os, sys
sys.stdout.reconfigure(encoding='utf-8')
from openpyxl import load_workbook
FILE = '目标文件.xlsx'
size_mb = os.path.getsize(FILE) / 1024 / 1024
print(f'文件大小: {size_mb:.1f} MB')
wb = load_workbook(FILE)
ws = wb.active
print(f'工作表: {ws.title}, 行: {ws.max_row}, 列: {ws.max_column}')
# 展示表头(列模式需要)
print('\n=== 表头 ===')
for col_idx in range(1, ws.max_column + 1):
h = ws.cell(row=1, column=col_idx).value
if h:
col_letter = chr(64 + col_idx) if col_idx 1 else NEW_HEADER
ws.cell(row=1, column=new_col).value = header_text
ws.cell(row=1, column=new_col).font = Font(name='Arial', size=10, bold=True)
# 填充内容
if FILL_VALUE is not None:
for row in range(2, total_rows + 1):
ws.cell(row=row, column=new_col).value = FILL_VALUE
if row % 50000 == 0:
print(f' 进度: {row}/{total_rows}')
print(f'已插入列{new_col} (原列{TARGET_IDX}的{DIRECTION})')
elif MODE == 'row':
# 行插入逻辑
insert_at = TARGET_IDX if DIRECTION == 'above' else TARGET_IDX + 1
for i in range(AMOUNT):
ws.insert_rows(insert_at)
new_row = insert_at
# 填充内容
if FILL_VALUE is not None:
for col in range(1, total_cols + 1):
ws.cell(row=new_row, column=col).value = FILL_VALUE
print(f'已插入行{new_row} (原行{TARGET_IDX}的{DIRECTION})')
print(f'\n保存中...')
wb.save(FILE)
print(f'完成,耗时 {time.time()-t0:.1f}s')
第四步:验证
wb = load_workbook(FILE, read_only=True, data_only=True)
ws = wb.active
if MODE == 'column':
new_col = TARGET_IDX if DIRECTION == 'left' else TARGET_IDX + 1
# 验证表头
if NEW_HEADER:
h = ws.cell(row=1, column=new_col).value
print(f'新列表头: "{h}" {"✓" if h == NEW_HEADER else "⚠️"}')
# 验证总列数
print(f'总列数: {ws.max_column} (原{ws.max_column - AMOUNT} + {AMOUNT})')
# 抽查
for row in [2, ws.max_row // 2, ws.max_row]:
v = ws.cell(row=row, column=new_col).value
print(f' 行{row}: {repr(v)[:30] if v else "(空)"}')
elif MODE == 'row':
new_row = TARGET_IDX if DIRECTION == 'above' else TARGET_IDX + 1
print(f'总行数: {ws.max_row} (原{ws.max_row - AMOUNT} + {AMOUNT})')
# 抽查新行的几个列
for col in [1, 2, min(3, ws.max_column)]:
v = ws.cell(row=new_row, column=col).value
print(f' 行{new_row}列{col}: {repr(v)[:30] if v else "(空)"}')
wb.close()
注意事项
- 列插入多列:从右到左处理
- 行插入多行:从下到上处理
- 公式引用:openpyxl 的 insert 会自动更新直接引用,但 INDIRECT/OFFSET 不会
- 合并单元格:插入位置与合并区域相交时,合并会自动扩展
- 操作前必备份:遵循 [[excel-safe-workflow]] 第零步——操作前自动备份(时间戳命名),成功后保留最新3份,失误后立即删除损坏文件并从备份恢复
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: YuYY2004
- Source: YuYY2004/excel-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.