working-with-spreadsheets
Excelファイルを扱い、数式や書式設定、財務モデルの基準に沿ってスプレッドシートを作成・編集し、データ分析や数式を多用する場面で、再計算や色分けの注意点などを考慮して効率的に作業するSkill。
📜 元の英語説明(参考)
Creates and edits Excel spreadsheets with formulas, formatting, and financial modeling standards. Use when working with .xlsx files, financial models, data analysis, or formula-heavy spreadsheets. Covers formula recalculation, color coding standards, and common pitfalls.
🇯🇵 日本人クリエイター向け解説
Excelファイルを扱い、数式や書式設定、財務モデルの基準に沿ってスプレッドシートを作成・編集し、データ分析や数式を多用する場面で、再計算や色分けの注意点などを考慮して効率的に作業するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o working-with-spreadsheets.zip https://jpskill.com/download/17322.zip && unzip -o working-with-spreadsheets.zip && rm working-with-spreadsheets.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17322.zip -OutFile "$d\working-with-spreadsheets.zip"; Expand-Archive "$d\working-with-spreadsheets.zip" -DestinationPath $d -Force; ri "$d\working-with-spreadsheets.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
working-with-spreadsheets.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
working-with-spreadsheetsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 2
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
スプレッドシートの操作
クイックスタート
from openpyxl import Workbook
wb = Workbook()
sheet = wb.active
sheet['A1'] = 'Revenue'
sheet['B1'] = 1000
sheet['B2'] = '=B1*1.1' # ハードコードされた値ではなく、数式を使用してください!
wb.save('output.xlsx')
重要なルール: ハードコードされた値ではなく、数式を使用する
Python で計算する代わりに、常に Excel の数式を使用してください。
# 間違い - 計算された値をハードコーディング
total = df['Sales'].sum()
sheet['B10'] = total # 5000 をハードコード
# 正しい - Excel の数式を使用
sheet['B10'] = '=SUM(B2:B9)'
財務モデルのカラーコーディング標準
| 色 | RGB | 用途 |
|---|---|---|
| 青色のテキスト | 0,0,255 | ハードコードされた入力、シナリオ値 |
| 黒色のテキスト | 0,0,0 | すべての数式と計算 |
| 緑色のテキスト | 0,128,0 | 他のワークシートからのリンク |
| 赤色のテキスト | 255,0,0 | 他のファイルへの外部リンク |
| 黄色の背景 | 255,255,0 | 注意が必要な主要な前提 |
from openpyxl.styles import Font
# 入力セル (ユーザーが変更可能)
sheet['B5'].font = Font(color='0000FF') # 青
# 数式セル
sheet['C5'] = '=B5*1.1'
sheet['C5'].font = Font(color='000000') # 黒
# シート間のリンク
sheet['D5'] = "=Sheet2!A1"
sheet['D5'].font = Font(color='008000') # 緑
数値書式設定の標準
# 桁区切り付きの通貨
sheet['B5'].number_format = '$#,##0'
# ゼロをダッシュとして表示
sheet['B5'].number_format = '$#,##0;($#,##0);-'
# 小数点以下 1 桁のパーセンテージ
sheet['C5'].number_format = '0.0%'
# バリュエーション倍率
sheet['D5'].number_format = '0.0x'
# 年をテキストとして (2,024 ではなく)
sheet['A1'] = '2024' # 文字列、数値ではない
ライブラリの選択
| タスク | ライブラリ | 例 |
|---|---|---|
| データ分析 | pandas | df = pd.read_excel('file.xlsx') |
| 数式と書式設定 | openpyxl | sheet['A1'] = '=SUM(B:B)' |
| 大容量ファイル (読み取り) | openpyxl | load_workbook('file.xlsx', read_only=True) |
| 大容量ファイル (書き込み) | openpyxl | Workbook(write_only=True) |
Excel ファイルの読み取り
import pandas as pd
from openpyxl import load_workbook
# pandas - データ分析
df = pd.read_excel('file.xlsx')
all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # DataFrame の辞書
# openpyxl - 数式を保持
wb = load_workbook('file.xlsx')
sheet = wb.active
print(sheet['A1'].value) # 数式の文字列を返します
# openpyxl - 計算された値を取得 (警告: 保存時に数式が失われます!)
wb = load_workbook('file.xlsx', data_only=True)
Excel ファイルの作成
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
sheet.title = 'Model'
# ヘッダー
sheet['A1'] = 'Metric'
sheet['B1'] = '2024'
sheet['A1'].font = Font(bold=True)
# 数式を含むデータ
sheet['A2'] = 'Revenue'
sheet['B2'] = 1000000
sheet['B2'].font = Font(color='0000FF') # 青 = 入力
sheet['A3'] = 'Growth'
sheet['B3'] = '=B2*0.1'
sheet['B3'].font = Font(color='000000') # 黒 = 数式
# 書式設定
sheet['B2'].number_format = '$#,##0'
sheet.column_dimensions['A'].width = 20
wb.save('model.xlsx')
既存ファイルの編集
from openpyxl import load_workbook
wb = load_workbook('existing.xlsx')
sheet = wb['Data'] # または wb.active
# セルの変更
sheet['A1'] = 'Updated Value'
sheet.insert_rows(2)
sheet.delete_cols(3)
# 新しいシートの追加
new_sheet = wb.create_sheet('Analysis')
new_sheet['A1'] = '=Data!B5' # シート間の参照
wb.save('modified.xlsx')
数式の再計算
openpyxl は数式を書き込みますが、値を計算しません。 LibreOffice を使用して再計算します。
# 再計算してエラーを確認
python recalc.py output.xlsx
スクリプトは JSON を返します。
{
"status": "success", // または "errors_found"
"total_errors": 0,
"total_formulas": 42,
"error_summary": {
"#REF!": {"count": 2, "locations": ["Sheet1!B5", "Sheet1!C10"]}
}
}
数式検証チェックリスト
構築前
- [ ] 最初に 2 ~ 3 個のサンプル参照をテストする
- [ ] 列のマッピングを確認する (列 64 = BL、BK ではない)
- [ ] 覚えておく: DataFrame の行 5 = Excel の行 6 (1 から始まるインデックス)
よくある落とし穴
- [ ] 値を使用する前に
pd.notna()で NaN を確認する - [ ] FY データは、多くの場合、50 以上の列 (一番右) にある
- [ ] 最初のマッチだけでなく、すべての出現箇所を検索する
- [ ] 除算の前に分母を確認する (#DIV/0!)
- [ ] シート間の参照が正しい形式 (
Sheet1!A1) を使用していることを確認する
構築後
- [ ]
recalc.pyを実行して、エラーを修正する - [ ] #REF!、#DIV/0!、#VALUE!、#NAME? = 0 を検証する
よくあるエラー
| エラー | 原因 | 修正 |
|---|---|---|
| #REF! | 無効なセル参照 | 削除された行/列を確認する |
| #DIV/0! | ゼロ除算 | IF チェックを追加する: =IF(B5=0,0,A5/B5) |
| #VALUE! | 間違ったデータ型 | セルに予期される型が含まれていることを確認する |
| #NAME? | 不明な関数 | スペル、テキストを囲む引用符を確認する |
検証
実行: python scripts/verify.py
関連スキル
building-nextjs-apps- スプレッドシートのアップロード用のフロントエンドscaffolding-fastapi-dapr- スプレッドシート処理用の API
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Working with Spreadsheets
Quick Start
from openpyxl import Workbook
wb = Workbook()
sheet = wb.active
sheet['A1'] = 'Revenue'
sheet['B1'] = 1000
sheet['B2'] = '=B1*1.1' # Use formulas, not hardcoded values!
wb.save('output.xlsx')
Critical Rule: Use Formulas, Not Hardcoded Values
Always use Excel formulas instead of calculating in Python.
# WRONG - Hardcoding calculated values
total = df['Sales'].sum()
sheet['B10'] = total # Hardcodes 5000
# CORRECT - Using Excel formulas
sheet['B10'] = '=SUM(B2:B9)'
Financial Model Color Coding Standards
| Color | RGB | Usage |
|---|---|---|
| Blue text | 0,0,255 | Hardcoded inputs, scenario values |
| Black text | 0,0,0 | ALL formulas and calculations |
| Green text | 0,128,0 | Links from other worksheets |
| Red text | 255,0,0 | External links to other files |
| Yellow background | 255,255,0 | Key assumptions needing attention |
from openpyxl.styles import Font
# Input cell (user changeable)
sheet['B5'].font = Font(color='0000FF') # Blue
# Formula cell
sheet['C5'] = '=B5*1.1'
sheet['C5'].font = Font(color='000000') # Black
# Cross-sheet link
sheet['D5'] = "=Sheet2!A1"
sheet['D5'].font = Font(color='008000') # Green
Number Formatting Standards
# Currency with thousands separator
sheet['B5'].number_format = '$#,##0'
# Zeros display as dash
sheet['B5'].number_format = '$#,##0;($#,##0);-'
# Percentages with one decimal
sheet['C5'].number_format = '0.0%'
# Valuation multiples
sheet['D5'].number_format = '0.0x'
# Years as text (not 2,024)
sheet['A1'] = '2024' # String, not number
Library Selection
| Task | Library | Example |
|---|---|---|
| Data analysis | pandas | df = pd.read_excel('file.xlsx') |
| Formulas & formatting | openpyxl | sheet['A1'] = '=SUM(B:B)' |
| Large files (read) | openpyxl | load_workbook('file.xlsx', read_only=True) |
| Large files (write) | openpyxl | Workbook(write_only=True) |
Reading Excel Files
import pandas as pd
from openpyxl import load_workbook
# pandas - data analysis
df = pd.read_excel('file.xlsx')
all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # Dict of DataFrames
# openpyxl - preserve formulas
wb = load_workbook('file.xlsx')
sheet = wb.active
print(sheet['A1'].value) # Returns formula string
# openpyxl - get calculated values (WARNING: loses formulas on save!)
wb = load_workbook('file.xlsx', data_only=True)
Creating Excel Files
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
sheet.title = 'Model'
# Headers
sheet['A1'] = 'Metric'
sheet['B1'] = '2024'
sheet['A1'].font = Font(bold=True)
# Data with formulas
sheet['A2'] = 'Revenue'
sheet['B2'] = 1000000
sheet['B2'].font = Font(color='0000FF') # Blue = input
sheet['A3'] = 'Growth'
sheet['B3'] = '=B2*0.1'
sheet['B3'].font = Font(color='000000') # Black = formula
# Formatting
sheet['B2'].number_format = '$#,##0'
sheet.column_dimensions['A'].width = 20
wb.save('model.xlsx')
Editing Existing Files
from openpyxl import load_workbook
wb = load_workbook('existing.xlsx')
sheet = wb['Data'] # Or wb.active
# Modify cells
sheet['A1'] = 'Updated Value'
sheet.insert_rows(2)
sheet.delete_cols(3)
# Add new sheet
new_sheet = wb.create_sheet('Analysis')
new_sheet['A1'] = '=Data!B5' # Cross-sheet reference
wb.save('modified.xlsx')
Formula Recalculation
openpyxl writes formulas but doesn't calculate values. Use LibreOffice to recalculate:
# Recalculate and check for errors
python recalc.py output.xlsx
The script returns JSON:
{
"status": "success", // or "errors_found"
"total_errors": 0,
"total_formulas": 42,
"error_summary": {
"#REF!": {"count": 2, "locations": ["Sheet1!B5", "Sheet1!C10"]}
}
}
Formula Verification Checklist
Before Building
- [ ] Test 2-3 sample references first
- [ ] Confirm column mapping (column 64 = BL, not BK)
- [ ] Remember: DataFrame row 5 = Excel row 6 (1-indexed)
Common Pitfalls
- [ ] Check for NaN with
pd.notna()before using values - [ ] FY data often in columns 50+ (far right)
- [ ] Search ALL occurrences, not just first match
- [ ] Check denominators before division (#DIV/0!)
- [ ] Verify cross-sheet references use correct format (
Sheet1!A1)
After Building
- [ ] Run
recalc.pyand fix any errors - [ ] Verify #REF!, #DIV/0!, #VALUE!, #NAME? = 0
Common Errors
| Error | Cause | Fix |
|---|---|---|
| #REF! | Invalid cell reference | Check deleted rows/columns |
| #DIV/0! | Division by zero | Add IF check: =IF(B5=0,0,A5/B5) |
| #VALUE! | Wrong data type | Check cell contains expected type |
| #NAME? | Unknown function | Check spelling, quotes around text |
Verification
Run: python scripts/verify.py
Related Skills
building-nextjs-apps- Frontend for spreadsheet uploadsscaffolding-fastapi-dapr- API for spreadsheet processing
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (5,601 bytes)
- 📎 scripts/verify.py (996 bytes)