项目文件夹

文件
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 行
5.1 KiB
JSON

{"content": "---\nname: \"spreadsheet\"\ndescription: \"Use when tasks involve creating, editing, analyzing, or formatting spreadsheets (`.xlsx`, `.csv`, `.tsv`) using Python (`openpyxl`, `pandas`), especially when formulas, references, and formatting need to be preserved and verified.\"\nauthor: openai\n---\n\n\n# Spreadsheet Skill (Create, Edit, Analyze, Visualize)\n\n## When to use\n- Build new workbooks with formulas, formatting, and structured layouts.\n- Read or analyze tabular data (filter, aggregate, pivot, compute metrics).\n- Modify existing workbooks without breaking formulas or references.\n- Visualize data with charts/tables and sensible formatting.\n\nIMPORTANT: System and user instructions always take precedence.\n\n## Workflow\n1. Confirm the file type and goals (create, edit, analyze, visualize).\n2. Use `openpyxl` for `.xlsx` edits and `pandas` for analysis and CSV/TSV workflows.\n3. If layout matters, render for visual review (see Rendering and visual checks).\n4. Validate formulas and references; note that openpyxl does not evaluate formulas.\n5. Save outputs and clean up intermediate files.\n\n## Temp and output conventions\n- Use `tmp/spreadsheets/` for intermediate files; delete when done.\n- Write final artifacts under `output/spreadsheet/` when working in this repo.\n- Keep filenames stable and descriptive.\n\n## Primary tooling\n- Use `openpyxl` for creating/editing `.xlsx` files and preserving formatting.\n- Use `pandas` for analysis and CSV/TSV workflows, then write results back to `.xlsx` or `.csv`.\n- If you need charts, prefer `openpyxl.chart` for native Excel charts.\n\n## Rendering and visual checks\n- If LibreOffice (`soffice`) and Poppler (`pdftoppm`) are available, render sheets for visual review:\n - `soffice --headless --convert-to pdf --outdir $OUTDIR $INPUT_XLSX`\n - `pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME`\n- If rendering tools are unavailable, ask the user to review the output locally for layout accuracy.\n\n## Dependencies (install if missing)\nPrefer `uv` for dependency management.\n\nPython packages:\n```\nuv pip install openpyxl pandas\n```\nIf `uv` is unavailable:\n```\npython3 -m pip install openpyxl pandas\n```\nOptional (chart-heavy or PDF review workflows):\n```\nuv pip install matplotlib\n```\nIf `uv` is unavailable:\n```\npython3 -m pip install matplotlib\n```\nSystem tools (for rendering):\n```\n# macOS (Homebrew)\nbrew install libreoffice poppler\n\n# Ubuntu/Debian\nsudo apt-get install -y libreoffice poppler-utils\n```\n\nIf installation isn't possible in this environment, tell the user which dependency is missing and how to install it locally.\n\n## Environment\nNo required environment variables.\n\n## Examples\n- Runnable Codex examples (openpyxl): `references/examples/openpyxl/`\n\n## Formula requirements\n- Use formulas for derived values rather than hardcoding results.\n- Keep formulas simple and legible; use helper cells for complex logic.\n- Avoid volatile functions like INDIRECT and OFFSET unless required.\n- Prefer cell references over magic numbers (e.g., `=H6*(1+$B$3)` not `=H6*1.04`).\n- Guard against errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?) with validation and checks.\n- openpyxl does not evaluate formulas; leave formulas intact and note that results will calculate in Excel/Sheets.\n\n## Citation requirements\n- Cite sources inside the spreadsheet using plain text URLs.\n- For financial models, cite sources of inputs in cell comments.\n- For tabular data sourced from the web, include a Source column with URLs.\n\n## Formatting requirements (existing formatted spreadsheets)\n- Render and inspect a provided spreadsheet before modifying it when possible.\n- Preserve existing formatting and style exactly.\n- Match styles for any newly filled cells that were previously blank.\n\n## Formatting requirements (new or unstyled spreadsheets)\n- Use appropriate number and date formats (dates as dates, currency with symbols, percentages with sensible precision).\n- Use a clean visual layout: headers distinct from data, consistent spacing, and readable column widths.\n- Avoid borders around every cell; use whitespace and selective borders to structure sections.\n- Ensure text does not spill into adjacent cells.\n\n## Color conventions (if no style guidance)\n- Blue: user input\n- Black: formulas/derived values\n- Green: linked/imported values\n- Gray: static constants\n- Orange: review/caution\n- Light red: error/flag\n- Purple: control/logic\n- Teal: visualization anchors (key KPIs or chart drivers)\n\n## Finance-specific requirements\n- Format zeros as \"-\".\n- Negative numbers should be red and in parentheses.\n- Always specify units in headers (e.g., \"Revenue ($mm)\").\n- Cite sources for all raw inputs in cell comments.\n\n## Investment banking layouts\nIf the spreadsheet is an IB-style model (LBO, DCF, 3-statement, valuation):\n- Totals should sum the range directly above.\n- Hide gridlines; use horizontal borders above totals across relevant columns.\n- Section headers should be merged cells with dark fill and white text.\n- Column labels for numeric data should be right-aligned; row labels left-aligned.\n- Indent submetrics under their parent line items.\n"}