xlsx
Skill này làm gì
Skill này dạy agent cách làm việc với file Excel và các bảng CSV hoặc TSV hàng loạt. Skill dành cho bất kỳ ai cần lập, sửa hoặc phân tích bảng tính.
Khi nào nên dùng
- ✓Khi bạn tải lên một file Excel hoặc CSV và muốn dữ liệu được phân tích hoặc làm sạch.
- ✓Khi bạn cần một bảng tính mới được tạo với công thức, định dạng hoặc biểu đồ.
- ✓Khi bạn muốn một bảng lộn xộn được sắp xếp lại thành bảng tính gọn gàng, dùng được.
Liên kết skill
https://github.com/HKUDS/DeepTutor/blob/main/deeptutor/skills/builtin/xlsx/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể làm sạch bảng tính này và thêm cho tôi một cột tổng hằng tháng không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent dùng thư viện Python để ghi dữ liệu, công thức, kiểu dáng và biểu đồ vào một workbook. Sau khi lưu, nó mở lại file để kiểm tra.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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:
- 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. - Live model (formulas that recompute on the user's later edits). Write real
formulas, and reference cells not literals (
=B5*(1+$B$6), not=B5*1.05). openpyxl can't set the cached value too. Ifshutil.which("soffice")succeeds, recalculate throughexecusingsubprocess.runand a relative_recalc/directory, replaceout.xlsxwith the recalculated copy, then remove_recalc/. Never use/tmpor 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).
``
Câu hỏi thường gặp
Nó có làm việc được với công thức không?
Có. Nó có thể viết công thức, nhưng một số giá trị chỉ cập nhật khi file được mở trong Excel hoặc ứng dụng bảng tính khác.
Nó có tạo được biểu đồ không?
Có. Skill cũng bao quát các ô gộp, định dạng số và workbook nhiều sheet.
Nó có xử lý file CSV không?
Có. Skill bao quát các bảng CSV và TSV hàng loạt cũng như file Excel.
Chi tiết
Mô tả gốc của tác giả
Read, create, or edit Excel spreadsheets (.xlsx/.xlsm) — sheet data, formulas, styles, charts, multi-sheet workbooks — and bulk .csv/.tsv tables; use whenever a spreadsheet is the input or the deliverable (extract/analyze data, add columns/formulas/formatting/charts, clean messy tables, build from scratch), but not for Google Sheets API or Word/PDF/script outputs.
repo: HKUDS/DeepTutor
Độ phổ biến
- Sao GitHub
- 54k
- Vị trí xếp hạng
- #3372
- Giấy phép
- Apache-2.0
- Cập nhật
- 31/10/2026
Bình luận
- …
Thêm skill từ kho mã này
deeptutor-cli
54kGiúp agent của bạn thiết lập và chạy DeepTutor, một nền tảng học tập, qua dòng lệnh, gồm knowledge base, sổ tay và ứng dụng web.
docx
54kGiúp agent của bạn đọc, tạo và chỉnh sửa file Word .docx, gồm báo cáo, bảng, tìm và thay thế, cùng các thay đổi được theo dõi kèm bình luận.
Giúp agent của bạn đọc, gộp, tách, điền và tạo file PDF, gồm lấy văn bản và bảng ra khỏi file.
pptx
54kGiúp agent của bạn tạo, đọc và chỉnh sửa bộ slide PowerPoint, gồm văn bản slide, ghi chú người thuyết trình, biểu đồ và hình ảnh.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.