Reads Excel (.xlsx) files and converts to Markdown format. Handles multiple sheets and large tables. Use when needing to read Excel spreadsheets. Requires openpyxl package.
Excel (.xlsx) ファイルを読み込んで Markdown テーブル形式に変換するスキルです。
# WSL環境でPythonスクリプトを実行
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx"
openpyxl パッケージが必要です:
wsl pip3 install openpyxl
User: "data.xlsx を読み込んで"
Assistant:
1. Windowsパスを WSL パスに変換
2. wsl python3 scripts/read_xlsx.py を実行
3. 全シートの内容を Markdown テーブルで表示
User: "data.xlsx の Sheet1 と Sheet2 だけ読み込んで"
Assistant:
1. スクリプトにシート名を指定して実行
2. 指定したシートのみ Markdown 化
User: "data.xlsx の最初の100行だけ読み込んで"
Assistant:
1. max_rows パラメータを指定して実行
2. 各シートの先頭100行のみ抽出
wsl python3 scripts/read_xlsx.py を実行# data.xlsx
**Total Sheets:** 3
---
## Sheet: Sheet1
**Dimensions:** 100 rows × 5 columns
| 列1 | 列2 | 列3 | 列4 | 列5 |
| --- | --- | --- | --- | --- |
| データ1 | データ2 | データ3 | データ4 | データ5 |
| ... | ... | ... | ... | ... |
---
## Sheet: Sheet2
**Dimensions:** 50 rows × 3 columns
| A | B | C |
| --- | --- | --- |
| 値1 | 値2 | 値3 |
| ... | ... | ... |
---
Python スクリプトは scripts/read_xlsx.py に配置されています。
主な機能:
使い方:
python scripts/read_xlsx.py <file_path> [sheet_names] [max_rows]
# 例
python scripts/read_xlsx.py data.xlsx
python scripts/read_xlsx.py data.xlsx 'Sheet1,Sheet2'
python scripts/read_xlsx.py data.xlsx 'Sheet1' 100
wsl pip3 install openpyxl
大きな Excel ファイルの場合:
# 行数を制限して読み込み
python scripts/read_xlsx.py large_file.xlsx '' 1000
Windows パスから WSL パスへの変換:
C:\Users\... → /mnt/c/Users/...D:\Projects\... → /mnt/d/Projects/...| ファイル形式 | 推奨スキル | 理由 |
|---|---|---|
| .xlsx (Excel) | xlsx-reader | Excelネイティブ |
| .xls (旧Excel) | pandas経由 | 別ツール必要 |
| .csv | 直接Read | テキストファイル |
| .tsv | 直接Read | テキストファイル |
# Sheet1 のみ
python scripts/read_xlsx.py data.xlsx 'Sheet1'
# 複数シート
python scripts/read_xlsx.py data.xlsx 'Sheet1,Sheet2,Sheet3'
# 各シートの先頭100行のみ
python scripts/read_xlsx.py large_file.xlsx '' 100
| 機能 | CSV | Excel (.xlsx) |
|---|---|---|
| 複数シート | ❌ | ✅ |
| セル書式 | ❌ | ⚠️(失われる) |
| 数式 | ❌ | ✅(評価後の値) |
| ファイルサイズ | 小 | 大 |
| 読み込み速度 | 速 | やや遅 |