---
name: spreadsheets
description: Create, read, edit, analyze, convert, chart, and validate spreadsheet files including XLSX, XLSM, XLS, CSV, and TSV. Use when a spreadsheet is a primary input or deliverable, or when tabular data must remain editable and auditable in workbook form.
title: spreadsheets
canonical_url: https://skilld.dev/gh/astrbotdevs/astrbot/spreadsheets
last_updated: 2026-10-29T11:16:36.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/charts.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/charts.md), [references/formatting.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/formatting.md), [references/formulas.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/formulas.md), [scripts/csv_to_xlsx.py](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/scripts/csv_to_xlsx.py), [scripts/inspect_workbook.py](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/scripts/inspect_workbook.py), [scripts/render_workbook.py](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/scripts/render_workbook.py), [scripts/validate_workbook.py](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/scripts/validate_workbook.py).
>
> If the user asked to install this Skill, run `npx skilld install astrbotdevs/astrbot/spreadsheets`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/spreadsheets`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/astrbotdevs/astrbot/spreadsheets) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/spreadsheets`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/spreadsheets --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/spreadsheets --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Work with spreadsheets

Use `openpyxl` for XLSX/XLSM authoring, `xlrd` for legacy XLS reading, `pandas` for substantial data cleaning or analysis, and the standard `csv` module for simple CSV/TSV work. Preserve the source unless the user explicitly requests an in-place edit.

## Choose the workflow

1. For a read-only question, inspect only the relevant sheets, labels, values, formulas, tables, charts, and comments. Do not export a modified copy.
2. For an existing workbook, study its structure and formatting before editing. Apply the smallest local change and extend nearby formulas, validation, conditional formatting, tables, and charts when the edited range requires it.
3. For a new workbook, separate inputs, calculations, and outputs when the task contains derived values. Keep calculations visible and auditable.
4. Save to a new file, reopen it, validate formulas and structure, and render every populated sheet when a renderer is available.

Use the bundled inspector before unfamiliar edits:

```text
python <this-skill-directory>/scripts/inspect_workbook.py input.xlsx
```

## Respect format boundaries

- Use `openpyxl.load_workbook(..., keep_vba=True)` for XLSM files and preserve the `.xlsm` extension. Do not claim that macros were inspected or are safe merely because they were preserved.
- Treat XLS as a legacy read-only source. `xlrd` reads values and basic metadata but does not provide reliable modern editing. Convert the result to XLSX or CSV instead of overwriting the XLS file.
- Preserve CSV/TSV delimiter, quoting, encoding, header order, and typed meaning. Keep identifiers such as ZIP codes and account numbers as text.
- Never change a workbook's file extension without actually converting its format.

## Keep formulas auditable

- Write derived values as formulas rather than hardcoded results.
- Place assumptions and raw inputs in visible cells or dedicated sheets.
- Avoid magic numbers inside formulas. Reference an assumption cell instead.
- Use correct absolute and relative references for fill behavior.
- Quote every cross-sheet name: `='Revenue Model'!B4`, even when the current name has no spaces.
- Prefer bounded ranges over full-column references in calculation-heavy formulas.
- Use helper cells when a formula becomes difficult to understand or audit.
- Add comments to important assumptions and source-backed inputs.
- Check for `#REF!`, `#DIV/0!`, `#VALUE!`, `#NAME?`, `#NUM!`, `#NULL!`, and unexpected circular references.

`openpyxl` writes formulas but does not calculate them. If formulas must be recalculated, open and save a copy with LibreOffice or Excel when available, then reopen the result with `data_only=False` and `data_only=True`. Never replace formulas with calculated constants merely to make validation pass. Read [formulas.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/formulas.md) for the detailed validation contract.

## Format by meaning

Read [formatting.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/formatting.md) before creating or substantially redesigning a workbook.

- Store dates, numbers, currency, and percentages as typed values with explicit number formats.
- Distinguish title, header, input, calculation, output, note, and warning roles consistently.
- Prefer restrained fills and light structural borders. Do not decorate every populated cell with a border.
- Freeze useful headers, enable filters, and use named tables for editable datasets.
- Prefer conditional formatting over one-time manual fills when color represents a value or status.
- Use data validation for editable categorical fields when practical.
- Size columns and rows deliberately. Widen before wrapping, cap very wide columns, and avoid formatting unused ranges.
- Hide gridlines only when explicit formatting already provides structure.

## Use charts deliberately

Read [charts.md](https://skilld.dev/api/skills-raw/astrbotdevs/astrbot/spreadsheets/references/charts.md) before creating or editing charts. Create a chart only when it improves comparison, trend, distribution, ranking, progress, or relationship understanding.

- Link chart series to worksheet ranges, not duplicated literal values.
- Keep units explicit and titles focused on one takeaway.
- Place charts in reserved areas without covering source data or controls.
- Verify categories, series orientation, source ranges, point counts, axes, and placement after saving.
- Prefer a compact table over a chart when exact values are the main point.

## Convert CSV or TSV

Use the bundled converter for a clean, typed, filterable workbook:

```text
python <this-skill-directory>/scripts/csv_to_xlsx.py input.csv output.xlsx
python <this-skill-directory>/scripts/csv_to_xlsx.py input.tsv output.xlsx --delimiter tab
```

The converter infers conservative scalar types, freezes the header, creates a table, applies number formats, and caps column widths. Inspect identifiers and locale-specific dates before accepting inferred types.

## Validate and render

Run structural validation after every create or edit operation:

```text
python <this-skill-directory>/scripts/validate_workbook.py output.xlsx
```

When LibreOffice and a PDF renderer are available, render the workbook:

```text
python <this-skill-directory>/scripts/render_workbook.py output.xlsx rendered
```

Inspect every rendered page at normal zoom. Check for clipped headers or values, unexpected blank pages, broken charts, unreadable colors, bad page breaks, missing glyphs, formula errors, and content outside the visible area. Rendering does not prove formula correctness; structural and formula validation remain required.

If rendering is unavailable, report that only structural validation was completed. Do not imply that a workbook passed visual QA.

## Finish

Deliver only the requested workbook or tabular output unless the user asks for previews or intermediates. Report the output path, important sheets or changes, formula/recalculation status, validation performed, and any limitation involving macros, legacy XLS, unsupported formulas, fonts, or rendering.
