Handle the request directly. Do NOT spawn sub-agents. Always write the output file the user requests, then verify it before delivering.
This is a vendor-neutral, general-purpose spreadsheet skill. It is not limited to finance and is explicitly built to work well in Chinese-language contexts: Chinese sheet names, headers and data; mixed CJK + ASCII; encodings beyond UTF-8 (GB18030/GBK) for CSV; full-width punctuation; CJK fonts during rendering; and Chinese number/date conventions. Finance-specific conventions are optional and isolated in their own section.
The golden loop for every task: READ → ACT → VERIFY. Never skip READ, never skip VERIFY.
# 0) One-time environment self-check (python, openpyxl, libreoffice, poppler, AND CJK fonts)
python3 SKILL_DIR/scripts/doctor.py
# 1) READ — always inspect structure before touching anything
python3 SKILL_DIR/scripts/xlsx_reader.py input.xlsx # sheets, dims, named ranges, macros, pivots, charts
# 2) ACT — pick ONE path (see Decision Guide below)
# - read-only analysis -> pandas
# - create new workbook -> XML template + xlsx_pack.py
# - edit / fill / fix existing -> unpack -> edit -> pack (zero format loss)
# 3) VERIFY — prove the file is correct and undamaged
python3 SKILL_DIR/scripts/formula_check.py output.xlsx --report
python3 SKILL_DIR/scripts/xlsx_render.py output.xlsx --out review/ # renders with CJK fonts
python3 SKILL_DIR/scripts/xlsx_reader.py output.xlsx --diff-against input.xlsx
If unsure which path to take, see the Decision Guide (section 2). If something breaks, see Troubleshooting (section 9). For Chinese-context specifics, see section 10.
| Task | When | Method | Guide |
|---|---|---|---|
| READ | analyze / summarize existing data, no changes | xlsx_reader.py + pandas |
references/read-analyze.md |
| CREATE | brand-new workbook from scratch | XML template → xlsx_pack.py |
references/create.md + references/format.md |
| EDIT | modify / fill an existing workbook | XML unpack → edit → pack | references/edit.md (+ format.md) |
| FIX | repair broken formulas / corruption | XML unpack → fix <f> nodes → pack |
references/fix.md |
| VALIDATE | check formulas & integrity | formula_check.py (+ recalc) |
references/validate.md |
| REVIEW | confirm result visually | xlsx_render.py → PNG/PDF/HTML |
references/visual-review.md |
CSV / TSV: for pure data work use pandas directly (mind the encoding — see section 10). To deliver an .xlsx, build it via the CREATE path so formatting and formulas are preserved.
xlsx_reader.py then pandas. Never modify the source.openpyxl.load_workbook(...).save() round-trip — it silently destroys VBA macros, pivot tables, charts, slicers, sparklines.libreoffice_recalc.py) and re-validate; if corruption, go to Troubleshooting.Format-preservation rule of thumb: if the file contains (or might contain) macros, pivots, charts, conditional formatting, named ranges, or sparklines, stay on the XML unpack/edit/pack path. xlsx_reader.py reports which of these are present.
references/read-analyze.md first)Start with xlsx_reader.py for structure discovery, then pandas for custom analysis. Never modify the source file.
.xlsx is always UTF-8 internally, but .csv/.tsv exported from Chinese Excel is often GB18030/GBK. Detect and decode (see section 10); do not assume UTF-8.f'{v:.2f}'. Never print 12875 when 12875.00 is required.df['营业收入'].sum(). Never re-derive column values before aggregating.pandas.read_excel(..., sheet_name=None) to enumerate sheets; .head() before full loads.references/create.md + references/format.md)Copy templates/minimal_xlsx/ → edit XML directly → pack with xlsx_pack.py.
<f>SUM(B2:B9)</f>), never a hardcoded number.=H6*(1+$B$3), not =H6*1.04).& < >, e.g. <c r="A1" t="inlineStr"><is><t>营业收入</t></is></c>. Always write XML as UTF-8.format.md.references/edit.md first)Workbook() for edit tasks. Always load/unpack the original file.vbaProject.bin, pivotTables/, pivotCache/, charts/, slicers, sparklines must survive unchanged.xlsx_reader.py --diff-against input.xlsx: confirm original sheet names, named ranges, pivots/macros, and a sample of original data are present. If verification fails, fix it before delivering.Never use an openpyxl round-trip on existing files. Instead: unpack → use helper scripts / edit XML → repack.
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
# Find target sheet XML via xl/workbook.xml -> xl/_rels/workbook.xml.rels
# <c r="B3"><f>SUM('销售数据'!D2:D13)</f><v></v></c>
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/xlsx_work/ --col G \
--sheet "Sheet1" --header "占比" \
--formula '=F{row}/$F$10' --formula-rows 2:9 \
--total-row 10 --total-formula '=SUM(G2:G9)' --numfmt '0.0%' \
--border-row 10 --border-style medium
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx
--border-row applies a top border to ALL cells in that row (not just the new column). Use for accounting-style total rows.
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
# Locate the row by its LABEL text (works for Chinese labels too):
# grep -n "办公租金" /tmp/xlsx_work/xl/worksheets/sheet*.xml
# (Chinese labels usually live in xl/sharedStrings.xml — grep there as well)
python3 SKILL_DIR/scripts/xlsx_insert_row.py /tmp/xlsx_work/ --at 5 \
--sheet "2025预算" --text A=水电费 \
--values B=3000 C=3000 D=3500 E=3500 \
--formula 'F=SUM(B{row}:E{row})' --copy-style-from 4
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx
Row lookup rule: when the task says “after row N (Label)”, find the row by searching for the label in sharedStrings.xml/worksheet XML and use the real row number + 1 for --at. xlsx_insert_row.py calls xlsx_shift_rows.py internally — do not call it separately.
Append a new <border> in xl/styles.xml, append an <xf> clone in <cellXfs> setting the new borderId, then apply that style index to every <c> in the row via the s attribute. Iterate over ALL cells A through the last column.
<border><left/><right/><top style="medium"/><bottom/><diagonal/></border>
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
# ... edit XML (UTF-8) ...
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx
sharedStrings.xml count/uniqueCount.calcChain.xml (delete it; the app rebuilds).vbaProject.bin on pack (keep order; store the macro blob).references/fix.md first)EDIT task. Unpack → fix broken <f> nodes / rebuild calcChain.xml → pack. Preserve all original sheets and data. Re-validate after.
references/validate.md first)formula_check.py file.xlsx --report (exit code 0 = safe). Flags #REF!, #DIV/0!, #VALUE!, #N/A, #NAME?, broken ranges, circular refs.libreoffice_recalc.py file.xlsx to recalculate and write back cached values (openpyxl does NOT evaluate formulas).references/visual-review.md first)Closes the “no visual interface” gap so a human can confirm results. xlsx_render.py forces CJK-capable fonts so Chinese text renders instead of showing tofu boxes (□□□).
python3 SKILL_DIR/scripts/xlsx_render.py output.xlsx --out review/ # one PNG per sheet
python3 SKILL_DIR/scripts/xlsx_render.py --diff input.xlsx output.xlsx --html review/diff.html # before/after
Review checklist: layout alignment, CJK text not clipped/tofu, number/date formats, error values, pivots/charts still render.
| Symptom | Cause | Fix |
|---|---|---|
| App shows “needs repair” on open | stale calcChain.xml, bad sharedStrings count, re-ordered/recompressed parts |
delete calcChain.xml; run formula_check.py; repack with xlsx_pack.py |
| Cells show old value or 0 after editing formula | openpyxl doesn’t calculate | run libreoffice_recalc.py, then re-render |
| Charts / pivots / macros vanished | openpyxl round-trip | redo via unpack/edit/pack; never Workbook().save() over existing file |
| Chinese text shows as 锟斤拷/锘/gibberish | wrong encoding | read/write XML as UTF-8; for CSV detect GB18030/GBK (section 10) |
| Chinese renders as □□□ boxes in PNG | missing CJK font | xlsx_render.py sets a CJK font; install Noto Sans CJK if doctor.py flags it |
| Wrong row edited | trusted prompt’s row number | locate by label text in the XML first |
Encoding
.xlsx/.xlsm internals are always UTF-8 — keep them UTF-8 on edit.import pandas as pd
for enc in ("utf-8-sig", "gb18030", "utf-16"):
try:
df = pd.read_csv(path, encoding=enc); break
except UnicodeDecodeError:
continueencoding="utf-8-sig" (BOM) so Excel shows Chinese correctly.Text / XML
& < >. Sheet names, named ranges, and headers may be Chinese — quote sheet names in formulas: SUM('销售数据'!D2:D13).,;:()% and full-width digits 123). Normalize to half-width for numeric parsing when needed (unicodedata.normalize('NFKC', s)).Numbers & currency
"¥"#,##0.00 (or "¥" full-width). For accounting style use _-"¥"* #,##0.00_-;-"¥"* #,##0.00.0!.0,,"亿" is unreliable; prefer a helper column that divides (=B2/100000000) with header “金额(亿元)”, keeping the source value intact.#,##0; percentage 0.0%.Dates
yyyy"年"m"月"d"日"; with weekday aaaa → 星期X. Keep the underlying value a real date serial, only the number format is Chinese.Rendering & fonts
xlsx_render.py (it selects an installed CJK font: Noto Sans CJK SC/TC, Source Han, WenQuanYi, or Microsoft YaHei if present). Verify with doctor.py.Layout
pypinyin (pinyin) or document the limitation.| Cell Role | Font Color | Hex |
|---|---|---|
| Hard-coded input / assumption | Blue | 0000FF |
| Formula / computed result | Black | 000000 |
| Cross-sheet reference formula | Green | 00B050 |
Finance display conventions (when applicable): zeros as -, negatives in red parentheses, multiples as 5.2x, units in headers (e.g. 营业收入(亿元)).
7w4.net提供免费和付费技能下载。
formula_check.py exit 0).python3 SKILL_DIR/scripts/doctor.py # NEW: env + CJK-font self-check
python3 SKILL_DIR/scripts/xlsx_reader.py input.xlsx # structure discovery
python3 SKILL_DIR/scripts/xlsx_reader.py out.xlsx --diff-against in.xlsx # NEW: structural diff for EDIT verification
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --json # formula validation (machine-readable)
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --report # formula validation (report)
python3 SKILL_DIR/scripts/libreoffice_recalc.py file.xlsx # recalc & write back cached values
python3 SKILL_DIR/scripts/xlsx_render.py file.xlsx --out review/ # NEW: render PNG/PDF with CJK fonts
python3 SKILL_DIR/scripts/xlsx_render.py --diff in.xlsx out.xlsx --html review/diff.html # NEW: before/after HTML
python3 SKILL_DIR/scripts/xlsx_unpack.py in.xlsx /tmp/work/ # unpack for XML editing
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/work/ out.xlsx # repack (preserves part order & macros)
python3 SKILL_DIR/scripts/xlsx_shift_rows.py /tmp/work/ insert 5 1 # shift rows for insertion
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/work/ --col G ... # add column with formulas
python3 SKILL_DIR/scripts/xlsx_insert_row.py /tmp/work/ --at 6 ... # insert row with data
references/quickstart.md — the READ→ACT→VERIFY loop (section 0) [NEW]
references/decision-guide.md — which path to take (section 2) [NEW]
references/read-analyze.md — reading & pandas analysis
references/create.md — building new workbooks
references/format.md — number formats, styles, colors, CJK
references/edit.md — EDIT integrity rules & XML editing
references/fix.md — repairing formulas / corruption
references/validate.md — formula validation & recalculation
references/visual-review.md — rendering & visual checks (CJK) [NEW]
references/troubleshooting.md — common failures & fixes (section 9) [NEW]
references/cjk-guide.md — Chinese / CJK handbook (section 10) [NEW] 这个 Skill 质量很高,文档写得非常详细全面,操作复杂 Excel 文件时能很好地保留原有格式和功能,对中文内容的处理也很到位。脚本工具配套完整,从检查到编辑再到验证都有覆盖。缺点是说明文档很专业但对新手来说有点多,另外缺少自动测试覆盖,复杂场景下可能存在未知问题。总体来说是专业级别的工具,适合需要频繁处理 Excel 报表或复杂表格的用户。