跳到主要内容

xlsx 精选

Read, create, or edit Excel spreadsheets (.xlsx/.xlsm) — sheet data,

数据 Codex CLIMCP 客户端 Apache-2.0 4.1 万
在 GitHub 打开

安装方式

cp -r deeptutor/skills/builtin/xlsx ~/.claude/skills/xlsx

把该 skill 目录放进客户端 skills 目录。不同客户端的目录可能不同,Claude Code 默认是 ~/.claude/skills/

整仓一次性获取:git clone --depth 1 https://github.com/HKUDS/DeepTutor.git

依赖与权限

  • 无需 API Key
  • 无需联网
  • 依赖外部命令:python pip docker soffice
  • 以上为按正文与 frontmatter 自动推断的信号,仅供参考;安装前建议先阅读原文。

SKILL.md 正文

来源 HKUDS/DeepTutor@6cf793b · 许可 Apache-2.0 · 内容未修改

Excel (.xlsx) workbooks

Runtime

Use exec with complete Python source (language: python). Prefer creating,

saving, reopening, and validating the workbook in one call; later calls can

revise the same relative filename. Follow the turn's User workspace

instructions for locating inputs, output boundaries, and presenting the

finished file.

Use openpyxl for cells, formulas, styles, charts, merged cells, multi-sheet

workbooks, number formats, and streaming large sheets. It is declared by every

supported DeepTutor installation. Do not assume pandas is installed: it exists

in the Docker runner but is not a direct dependency of every pip/source install.

THE critical gotcha: openpyxl writes formulas but never computes them

ws["B10"] = "=SUM(B2:B9)" stores the formula string. openpyxl has no formula

engine — the cached value stays empty (or stale, on an edited file). So:

  • A workbook you create/edit with openpyxl opens fine in Excel/LibreOffice (they

recompute on open), but its cached values are wrong until then.

  • Anything reading cached values first — data_only=True, another

pandas/openpyxl pass, or a downstream tool — sees blanks/stale data.

Pick by what the deliverable needs:

  1. Static numbers (most common). If the user just needs correct values and

the sheet need not stay live, compute in Python and write the number, not

a formula string: ws["B10"] = sum(c.value for c in ws["B2:B9"][0]). Correct

immediately, no recalc needed.

  1. Live model (formulas that recompute on the user's later edits). Write real

formulas, and reference cells not literals (=B5(1+$B$6), not =B51.05).

openpyxl can't set the cached value too. If shutil.which("soffice") succeeds,

recalculate through exec using subprocess.run and a

relative _recalc/ directory, replace out.xlsx with the recalculated copy,

then remove _recalc/. Never use /tmp or search for a desktop installation.

A later exec call can see the same bare filename. If LibreOffice is

absent, warn that formulas populate when the user opens the file in Excel.

Reading

from openpyxl import load_workbook

wb = load_workbook("in.xlsx", read_only=True, data_only=False)
for sheet_name in wb.sheetnames:
    ws = wb[sheet_name]
    for row in ws.iter_rows(values_only=True):
        print(row)

To read computed results of formulas (not the formula text), use openpyxl

with data_only=True — returns the value Excel last cached:

from openpyxl import load_workbook

wb = load_workbook("in.xlsx", data_only=True)
val = wb["Sheet1"]["B10"].value  # None if Excel never opened/saved the file

Gotcha: never save() a workbook loaded with data_only=True — that discards

every formula permanently (verified: the cell becomes None). Load twice if you

need both formulas and values.

Large file: load_workbook(path, read_only=True) streams rows cheaply.

Creating

from openpyxl import Workbook, load_workbook
from openpyxl.styles import Font, PatternFill, Alignment

wb = Workbook()
ws = wb.active
ws.title = "Summary"
ws.append(["Region", "Sales"])  # header row
for r in [("West", 120), ("East", 95)]:
    ws.append(r)
ws["B4"] = "=SUM(B2:B3)"  # see formula gotcha above

ws["A1"].font = Font(bold=True)
ws["A1"].fill = PatternFill("solid", fgColor="DDDDDD")
ws["A1"].alignment = Alignment(horizontal="center")
ws["B2"].number_format = "#,##0"  # thousands separator
ws.column_dimensions["A"].width = 18
ws.freeze_panes = "A2"  # freeze header
wb.create_sheet("Detail")  # second sheet
wb.save("out.xlsx")

# Validate immediately; later exec calls can also reopen this relative path.
check = load_workbook("out.xlsx", data_only=False)
assert check.sheetnames, "generated workbook has no worksheets"
import zipfile

with zipfile.ZipFile("out.xlsx") as package:
    assert package.testzip() is None, "generated XLSX has a corrupt ZIP member"

For large exports, use openpyxl's write-only mode and append rows without

holding every cell object in memory:

from openpyxl import Workbook

wb = Workbook(write_only=True)
ws = wb.create_sheet("Data")
ws.append(["id", "value"])
for row in rows:
    ws.append(row)
wb.save("out.xlsx")

Editing (preserve existing formatting)

load_workbook keeps styles, formulas, merged cells, charts intact — edit only

what you touch. Do NOT round-trip through pandas to preserve formatting (pandas

rewrites the whole sheet, losing styles).

from openpyxl import load_workbook

wb = load_workbook("in.xlsx")  # keep formulas (data_only=False)
ws = wb["Sheet1"]
ws["C2"] = "Updated"
wb.save("out.xlsx")  # preserve the source; present the new file

Match the file's existing conventions (font, number formats, colors) rather than

imposing new ones — an established template wins over any default.

When inserting/deleting rows or columns (ws.insert_rows, ws.delete_cols),

openpyxl does not rewrite formulas that reference shifted cells. Re-point

affected formulas yourself, or avoid structural shifts in formula-heavy sheets.

Charts

from openpyxl.chart import BarChart, Reference

ch = BarChart()
ch.title = "Sales"
data = Reference(ws, min_col=2, min_row=1, max_row=3)  # include header for title
cats = Reference(ws, min_col=1, min_row=2, max_row=3)
ch.add_data(data, titles_from_data=True)
ch.set_categories(cats)
ws.add_chart(ch, "E2")

LineChart / PieChart / ScatterChart follow the same shape.

Verifying you produced clean output

In the same exec Python call, reload and scan for error strings after writing.

These mean broken formulas

that recalc surfaced (#REF! bad reference, #DIV/0! zero denominator,

#VALUE! type mismatch, #NAME? unknown function, #N/A):

from openpyxl import load_workbook

wb = load_workbook("out.xlsx", data_only=True)
errs = [
    f"{s}!{c.coordinate}={c.value}"
    for s in wb.sheetnames
    for row in wb[s].iter_rows()
    for c in row
    if isinstance(c.value, str) and c.value.startswith("#")
]
print(errs or "clean")

This only catches errors in cached values. If you wrote formulas and couldn't

recalc (no soffice), cached values are blank, so the check is meaningful only

after a recalc or after Excel opens the file. Writing computed numbers (option 1)

sidesteps this.

CSV / TSV

import csv

with open("in.csv", newline="", encoding="utf-8-sig") as source:
    rows = list(csv.reader(source))  # delimiter="\t" for TSV
with open("out.csv", "w", newline="", encoding="utf-8") as target:
    csv.writer(target).writerows(rows)

For messy input (junk rows, header not on row 1, ragged columns), inspect a

bounded sample and explicitly normalize only the requested rows/columns.

Raw OOXML (rarely needed)

openpyxl covers essentially all xlsx features; reach for raw XML only for the

narrow cases it can't express (e.g. preserving an exotic part it drops on

re-save). An .xlsx is a ZIP: xl/workbook.xml, xl/worksheets/sheet1.xml,

xl/sharedStrings.xml, plus [Content_Types].xml and _rels/. Unzip with

stdlib zipfile, edit the part, re-zip — keep [Content_Types].xml and every

.rels consistent, keep IDs unique, and don't pretty-print into value-bearing

text nodes. Correctness check = it opens in Excel with no repair prompt.

质量与来源

所属仓库
HKUDS/DeepTutor
仓库星标
4.1 万
最近更新
今天
采集时间
今天
commit
6cf793bd868b
内容指纹
sha256:9f5e476f8692ff7
文件路径
deeptutor/skills/builtin/xlsx/SKILL.md

相似 Skill

更多「数据」
freehire-search
Use this skill to search live software / tech / data / engineering job listings across many countries and markets (and remote) via the freehire.me aggregator's public API, or to look up a specific posting. It aggregates roles from ~50 ATS platforms into one schema, so a single skill covers many markets — but its faceted filtering (skills, category, seniority) is tuned tech-first, so scope triggers to technical roles. Trigger phrases: find a tech job, software job search, developer jobs, engineering vacancies, data/ML jobs, DevOps roles, remote developer jobs, "are there any <tech role> jobs in <place>", look up this freehire job posting.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI
jobbank-search
Make sure to use this skill whenever the user mentions anything related to job searching on Akademikernes Jobbank, jobbank.dk, or looking for academic or highly educated positions in Denmark — even if they don't mention jobbank.dk explicitly. Also invoke this skill for questions about Danish job listings, graduate trainee positions, Ph.d. jobs, or finding work in specific industries or regions in Denmark. Trigger phrases include: jobbank, akademikernes jobbank, jobs denmark, academic jobs denmark, find job denmark, highly educated jobs, graduate job denmark, trainee position denmark, ph.d. position denmark, postdoc denmark, studiejob, fuldtidsjob, deltidsjob, vikariat, freelance job, praktikplads, job søgning, jobsøgning, søg job, ledige stillinger, nye jobs, it jobs denmark, engineering jobs denmark, marketing jobs denmark, finance jobs denmark, healthcare jobs denmark, remote job denmark, fjernarbejde, job københavn, job aarhus, job odense, nyuddannede job, job til nyuddannede, international job denmark, jobbank søgning, find stilling, data scientist job, software developer job, projektleder stilling, konsulent job, data analyse job.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI
jobdanmark-search
Make sure to use this skill whenever the user mentions anything related to Danish job listings, job search in Denmark, finding work in Denmark, or job vacancies on Jobdanmark — even if they don't explicitly mention jobdanmark.dk. Also invoke this skill for questions about specific Danish job categories, municipalities, job types, or salaries in a job-search context. Trigger phrases include: danish jobs, jobs in denmark, find job denmark, job search denmark, danish job listings, jobdanmark, job opslag, find job, jobsøgning, ledige stillinger, stillingsopslag, job i Danmark, fuldtidsjob, deltidsjob, studiejob, praktikplads, elev, fleksjob, IT job denmark, sygeplejersker job, håndværker job, ingeniør job, pædagog job, kontor job, leder job, salg job, hotel job, kirke job, job aarhus, job københavn, job odense, job aalborg, job sjælland, job jylland, job fyn, jobkategorier denmark, ledige job, ansøgningsfrist, søg job, job opslaget, jobopslag, danish vacancies, work in denmark, employment denmark, job denmark, jobs near me denmark, apprentice denmark, internship denmark, part-time denmark, full-time denmark.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI
jobindex-search
Make sure to use this skill whenever the user wants to search for jobs in Denmark, find Danish job listings, look up a specific job posting, or asks anything about the Danish job market — even if they don't mention jobindex.dk explicitly. Invoke this skill for questions about open positions, job vacancies, hiring in Denmark, job opportunities in Danish cities or sectors, or when the user wants to find work in Denmark. Also trigger for phrases like "find me a job", "are there any jobs for X in Copenhagen", or "what jobs are available in Aarhus" when the context is Denmark. Trigger phrases include: jobindex, jobsøgning, job i Danmark, ledige stillinger, job opslag, find job, stillingopslag, jobannonce, job vacancy denmark, danish jobs, jobs in denmark, job search denmark, work in denmark, find work denmark, IT jobs denmark, engineer jobs denmark, developer jobs copenhagen, marketing jobs aarhus, jobs aarhus, jobs copenhagen, jobs odense, jobs aalborg, job openings denmark, hiring denmark, job listings denmark, python jobs denmark, grafisk designer job, data engineer job, softwareudvikler job, full stack developer job danmark.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI
jobnet-search
Make sure to use this skill whenever the user mentions anything related to Danish job searching, job listings, job vacancies, employment opportunities in Denmark, or the Danish government job portal — even if they don't mention jobnet.dk explicitly. Also invoke this skill for questions about specific job titles, occupations, employers, or regions in a Danish employment context. This skill covers the official Danish public job portal operated by STAR (Styrelsen for Arbejdsmarked og Rekruttering). Trigger phrases include: danish jobs, danish job search, jobnet, jobnet.dk, find job denmark, danish employment, job i danmark, job på jobnet, offentlige job, stillinger i det offentlige, public sector jobs denmark, government jobs denmark, STAR jobs, job ledige stillinger, ledig stilling, søg job, job opslag, job vacancy denmark, stillingopslag, jobopslag, sygepleje job, ingeniør job, lærer job, pædagog job, it-job denmark, jobs in copenhagen, jobs in aarhus, jobs in odense, deltidsjob, fuldtidsjob, fastansættelse, tidsbegrænset ansættelse, fleksjob, sygeplejerske job, social worker job denmark, occupation search denmark, esco occupation, job deadline, ansøgningsfrist, søg efter job, full time job denmark, part time job denmark.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI
linkedin-search
Use this skill whenever the user wants to search for jobs in any location or market, find job listings, or look up a specific job posting — in any country, city, or remotely. Invoke for open positions, vacancies, and hiring across any sector or role (software, data, design, marketing, finance, legal, operations, etc.). The location is always supplied explicitly by the user. Trigger phrases: find a job, job search, search for jobs, job openings, vacancies, hiring, positions open, remote jobs, "are there any X jobs in <place>", look up this job posting.
精选 MadsLorentzen/ai-job-search 4.6 万 原文
Claude CodeCodex CLI