
Xlsx Reader
- 76 installs
- Updated January 23, 2026
- childbamboo/claude-code-marketplace-sample
Read Excel (.xlsx) files across multiple sheets and convert them to Markdown tables using an openpyxl script in WSL.
About
Reads .xlsx spreadsheets across sheets and large tables and converts them to Markdown, with sheet and row limits. Used when a developer needs to read or convert Excel files.
- Handles multiple sheets and large tables
- Sheet and row filtering via openpyxl
Xlsx Reader by the numbers
- 76 all-time installs (skills.sh)
- Ranked #345 of 688 Office & Documents skills by installs in the Skillselion catalog
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/childbamboo/claude-code-marketplace-sample --skill xlsx-readerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 76 |
|---|---|
| Last updated | January 23, 2026 |
| Repository | childbamboo/claude-code-marketplace-sample ↗ |
What it does
Read Excel (.xlsx) files across multiple sheets and convert them to Markdown tables using an openpyxl script in WSL.
Files
Excel Reader
Excel (.xlsx) ファイルを読み込んで Markdown テーブル形式に変換するスキルです。
クイックスタート
基本的な使い方
# WSL環境でPythonスクリプトを実行
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx"Markdown形式で保存
1. スクリプトでデータ抽出 2. Write ツールで .md ファイルに保存
前提条件
openpyxl パッケージが必要です:
wsl pip3 install openpyxl使用例
例1: Excel ファイルを読み込んで表示
User: "data.xlsx を読み込んで"
Assistant:
1. Windowsパスを WSL パスに変換
2. wsl python3 scripts/read_xlsx.py を実行
3. 全シートの内容を Markdown テーブルで表示例2: 特定のシートのみ読み込み
User: "data.xlsx の Sheet1 と Sheet2 だけ読み込んで"
Assistant:
1. スクリプトにシート名を指定して実行
2. 指定したシートのみ Markdown 化例3: 大きなファイルの一部のみ読み込み
User: "data.xlsx の最初の100行だけ読み込んで"
Assistant:
1. max_rows パラメータを指定して実行
2. 各シートの先頭100行のみ抽出ワークフロー
単一ファイルの読み込み
1. ユーザーが Excel ファイルパスを指定 2. Windows パスを WSL パス形式に変換 3. wsl python3 scripts/read_xlsx.py を実行 4. Markdown テーブルとして表示または保存
複数シートの処理
1. 全シート名を取得 2. 各シートをテーブルに変換 3. シートごとに見出しを付けて整理
出力形式
Markdown 構造
# 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 に配置されています。
主な機能:
- 複数シートの読み込み
- Markdown テーブル形式への変換
- シート指定
- 行数制限
- エラーハンドリング
使い方:
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対応機能
- ✅ 複数シートの読み込み
- ✅ Markdown テーブル形式
- ✅ シート指定
- ✅ 行数制限
- ✅ セルの値取得(計算式の結果)
- ⚠️ セルの書式情報は失われる
- ⚠️ 画像・グラフは抽出不可
- ⚠️ マクロは実行されない
制限事項
- セルの書式(色、フォントなど)は失われます
- 画像、グラフ、図形は抽出されません
- マクロは実行されません
- 計算式は評価後の値のみ取得
- 非常に大きなファイルはメモリ制約に注意
トラブルシューティング
openpyxl がインストールされていない
wsl pip3 install openpyxlファイルが開けない
- ファイルが Excel で開かれていないか確認
- .xlsx 形式か確認(.xls は非対応)
- ファイルのアクセス権限を確認
- ファイルが破損していないか確認
メモリ不足エラー
大きな 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 '' 100CSVとの違い
| 機能 | CSV | Excel (.xlsx) |
|---|---|---|
| 複数シート | ❌ | ✅ |
| セル書式 | ❌ | ⚠️(失われる) |
| 数式 | ❌ | ✅(評価後の値) |
| ファイルサイズ | 小 | 大 |
| 読み込み速度 | 速 | やや遅 |
関連ツール
- csv-reader: CSV ファイル用(Read ツールで直接可能)
- pandas: より高度なデータ処理が必要な場合
- xlrd: 旧形式 .xls ファイル用
バージョン履歴
- v1.0.0 (2026-01-06): 初期リリース
- 基本的な Excel 読み込み機能
- Markdown テーブル変換
- 複数シート対応
- WSL環境での動作
Excel Reader Skill
Excel (.xlsx) ファイルを読み込んで Markdown テーブル形式に変換するスキルです。
ファイル構成
xlsx-reader/
├── SKILL.md # メインスキル定義(Claude が読む)
├── README.md # このファイル(人間向けドキュメント)
└── scripts/
└── read_xlsx.py # Excel 読み込み用 Python スクリプトインストール
前提条件
- WSL (Windows Subsystem for Linux)
- Python 3.x
- openpyxl パッケージ
セットアップ
# openpyxl のインストール
wsl pip3 install openpyxl使い方
Claude に以下のように依頼します:
「C:\Users\keita\repos\data.xlsx を読み込んで」Claude が自動的に: 1. Windows パスを WSL パスに変換 2. スクリプトを実行してデータ抽出 3. Markdown テーブル形式で表示 4. 必要に応じて Markdown ファイルとして保存
スクリプトの直接実行
# 基本的な使い方(全シート)
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx"
# 特定のシートのみ
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx" "Sheet1,Sheet2"
# 行数制限(各シート100行まで)
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx" "" 100
# 出力をファイルに保存
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/file.xlsx" > output.md機能
データ抽出
- ✅ 全シートの読み込み
- ✅ 特定シートの指定
- ✅ 行数制限
- ✅ セルの値取得
- ✅ 計算式の評価後の値
Markdown 変換
- ✅ テーブル形式
- ✅ シートごとに見出し付き
- ✅ 行数・列数の情報
- ✅ 空シートの処理
制限事項
- ❌ セルの書式(色、フォントなど)
- ❌ 画像、グラフ、図形
- ❌ マクロの実行
- ❌ ピボットテーブル
- ❌ .xls 形式(旧Excel)
出力例
# sales_data.xlsx
**Total Sheets:** 2
---
## Sheet: 2024年度売上
**Dimensions:** 13 rows × 4 columns
| 月 | 売上 | 目標 | 達成率 |
| --- | --- | --- | --- |
| 1月 | 1000000 | 950000 | 105% |
| 2月 | 1200000 | 1100000 | 109% |
| 3月 | 1500000 | 1300000 | 115% |
| ... | ... | ... | ... |
---
## Sheet: 商品別
**Dimensions:** 20 rows × 3 columns
| 商品名 | 数量 | 金額 |
| --- | --- | --- |
| 商品A | 100 | 500000 |
| 商品B | 150 | 750000 |
| ... | ... | ... |
---トラブルシューティング
openpyxl が見つからない
wsl pip3 install openpyxlファイルが開けない
原因1: ファイルが開かれている
- Excel でファイルを閉じる
原因2: .xls 形式(旧Excel)
- .xlsx 形式に保存し直す
- または pandas を使用
原因3: ファイルが破損
- Excel で開いて修復を試みる
シートが見つからない
# まず全シートを確認
wsl python3 scripts/read_xlsx.py file.xlsx
# シート名を正確に指定(大文字小文字を区別)
wsl python3 scripts/read_xlsx.py file.xlsx "売上データ"メモリ不足
大きな Excel ファイルの場合:
# 行数を制限
wsl python3 scripts/read_xlsx.py large_file.xlsx "" 1000
# または特定のシートのみ
wsl python3 scripts/read_xlsx.py large_file.xlsx "Sheet1" 500開発
スクリプトの修正
scripts/read_xlsx.py を編集して機能を追加・修正できます。
カスタマイズ例
特定の範囲のみ読み込み
# A1:D10 の範囲のみ
for row in sheet['A1':'D10']:
for cell in row:
print(cell.value)セルの書式情報を取得
from openpyxl import load_workbook
wb = load_workbook('file.xlsx') # read_only=False
sheet = wb['Sheet1']
cell = sheet['A1']
# 書式情報
print(cell.font.color)
print(cell.fill.fgColor)テスト
# テスト用の Excel ファイルで動作確認
wsl python3 scripts/read_xlsx.py "/mnt/c/path/to/test.xlsx"パフォーマンス
処理時間の目安
| ファイルサイズ | 行数 | 処理時間 |
|---|---|---|
| 小(< 1MB) | < 1,000 | < 1秒 |
| 中(1-10MB) | 1,000-10,000 | 1-5秒 |
| 大(> 10MB) | > 10,000 | 5-30秒 |
最適化
1. read_only モード使用(既に実装済み)
- メモリ使用量削減
- 読み込み速度向上
2. 行数制限
- 大きなファイルは部分的に読み込み
3. 不要なシートをスキップ
- 必要なシートのみ指定
関連スキル
- csv-reader: CSV ファイル用(Read ツールで対応可能)
- docx-reader: Word 文書用
- pdf-reader: PDF 文書用
使用ライブラリ
openpyxl
- 機能: Excel 2010+ (.xlsx) の読み書き
- 特徴:
- 純粋な Python 実装
- 計算式の評価(data_only=True)
- read_only モードでメモリ効率化
- セル書式情報の取得も可能
代替ライブラリ
- xlrd: 旧形式 .xls 用
- pandas: データ分析・集計が必要な場合
- pyexcel: 複数形式対応
Excel 形式の違い
| 形式 | 拡張子 | 推奨ツール |
|---|---|---|
| Excel 2007+ | .xlsx | openpyxl |
| Excel 97-2003 | .xls | xlrd |
| CSV | .csv | Read tool |
| TSV | .tsv | Read tool |
| OpenDocument | .ods | pyexcel |
ライセンス
このスキルは個人プロジェクト用です。
バージョン
- v1.0.0 (2026-01-06)
- 初期リリース
- 基本的な Excel 読み込み機能
- Markdown テーブル変換
- 複数シート対応
- シート指定・行数制限機能
- WSL環境での動作確認済み
#!/usr/bin/env python3
"""
Excel Reader Script
Reads Excel (.xlsx) files and converts to Markdown format.
"""
import sys
import os
try:
from openpyxl import load_workbook
except ImportError:
print("Error: openpyxl is not installed.")
print("Please install it with: pip install openpyxl")
sys.exit(1)
def read_xlsx(file_path, sheet_names=None, max_rows=None):
"""
Read Excel file and convert to Markdown.
Args:
file_path (str): Path to the Excel file
sheet_names (list): List of sheet names to read (None = all sheets)
max_rows (int): Maximum rows to read per sheet (None = all rows)
Returns:
str: Markdown formatted content
"""
try:
# Use normal mode to ensure dimensions are calculated correctly
workbook = load_workbook(file_path, data_only=True)
markdown_content = []
# Add document header
markdown_content.append(f"# {os.path.basename(file_path)}\n")
markdown_content.append(f"**Total Sheets:** {len(workbook.sheetnames)}\n")
markdown_content.append("---\n")
# Process each sheet
sheets_to_process = sheet_names if sheet_names else workbook.sheetnames
for sheet_name in sheets_to_process:
if sheet_name not in workbook.sheetnames:
markdown_content.append(f"\n⚠️ Sheet '{sheet_name}' not found\n")
continue
sheet = workbook[sheet_name]
markdown_content.append(f"\n## Sheet: {sheet_name}\n")
# Get dimensions
max_row = sheet.max_row if sheet.max_row else 0
max_col = sheet.max_column if sheet.max_column else 0
if max_rows and max_row > max_rows:
markdown_content.append(f"*Showing first {max_rows} of {max_row} rows*\n")
max_row = max_rows
markdown_content.append(f"**Dimensions:** {max_row} rows × {max_col} columns\n")
# Check if sheet is empty
if max_row == 0 or max_col == 0 or max_row is None or max_col is None:
markdown_content.append("\n*(Empty sheet)*\n")
continue
# Convert to Markdown table
table_md = convert_sheet_to_markdown(sheet, max_row, max_col)
markdown_content.append(f"\n{table_md}\n")
markdown_content.append("\n---\n")
workbook.close()
return '\n'.join(markdown_content)
except FileNotFoundError:
return f"Error: File not found: {file_path}"
except Exception as e:
return f"Error reading Excel file: {str(e)}"
def convert_sheet_to_markdown(sheet, max_row, max_col):
"""
Convert Excel sheet to Markdown table.
Args:
sheet: openpyxl worksheet object
max_row (int): Maximum row to read
max_col (int): Maximum column to read
Returns:
str: Markdown table
"""
markdown_lines = []
# Read all cells
rows = []
for row_idx in range(1, max_row + 1):
row_data = []
for col_idx in range(1, max_col + 1):
cell = sheet.cell(row=row_idx, column=col_idx)
value = cell.value
# Format cell value
if value is None:
value = ""
else:
value = str(value).strip()
row_data.append(value)
rows.append(row_data)
if not rows:
return "*(No data)*"
# Create Markdown table
# Header row
header = rows[0]
markdown_lines.append("| " + " | ".join(header) + " |")
# Separator row
markdown_lines.append("| " + " | ".join(["---"] * len(header)) + " |")
# Data rows
for row in rows[1:]:
# Pad row if necessary
while len(row) < len(header):
row.append("")
markdown_lines.append("| " + " | ".join(row[:len(header)]) + " |")
return '\n'.join(markdown_lines)
def main():
"""Main entry point for the script."""
if len(sys.argv) < 2:
print("Usage: python read_xlsx.py <file_path> [sheet_names] [max_rows]")
print("\nExamples:")
print(" python read_xlsx.py data.xlsx")
print(" python read_xlsx.py data.xlsx 'Sheet1,Sheet2'")
print(" python read_xlsx.py data.xlsx 'Sheet1' 100")
sys.exit(1)
file_path = sys.argv[1]
if not os.path.exists(file_path):
print(f"Error: File not found: {file_path}")
sys.exit(1)
if not file_path.lower().endswith('.xlsx'):
print("Warning: File does not have .xlsx extension")
# Parse sheet names
sheet_names = None
if len(sys.argv) > 2 and sys.argv[2]:
sheet_names = [s.strip() for s in sys.argv[2].split(',')]
# Parse max rows
max_rows = None
if len(sys.argv) > 3:
try:
max_rows = int(sys.argv[3])
except ValueError:
print(f"Warning: Invalid max_rows value: {sys.argv[3]}")
content = read_xlsx(file_path, sheet_names, max_rows)
print(content)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
"""
Excel to JSON Converter
Converts Excel (.xlsx) files to JSON format.
"""
import json
import sys
import os
from datetime import datetime
try:
from openpyxl import load_workbook
except ImportError:
print("Error: openpyxl is not installed.")
print("Please install it with: pip install openpyxl")
sys.exit(1)
def excel_to_json(file_path, max_rows=None):
"""
Convert Excel file to JSON format.
Args:
file_path (str): Path to the Excel file
max_rows (int): Maximum rows to include per sheet (None = all)
Returns:
dict: JSON-formatted data
"""
wb = load_workbook(file_path, data_only=True)
result = {
"filename": os.path.basename(file_path),
"total_sheets": len(wb.sheetnames),
"sheets": {}
}
for sheet_name in wb.sheetnames:
sheet = wb[sheet_name]
max_row = sheet.max_row if sheet.max_row else 0
max_col = sheet.max_column if sheet.max_column else 0
if max_row == 0 or max_col == 0:
result["sheets"][sheet_name] = {
"dimensions": {"rows": 0, "columns": 0},
"data": []
}
continue
# Limit rows if specified
if max_rows and max_row > max_rows:
actual_rows = max_rows
else:
actual_rows = max_row
# Read header row
headers = []
for col_idx in range(1, max_col + 1):
cell = sheet.cell(row=1, column=col_idx)
header = str(cell.value) if cell.value else f"column_{col_idx}"
headers.append(header)
# Read data rows
data = []
for row_idx in range(2, actual_rows + 1):
row_data = {}
for col_idx in range(1, max_col + 1):
cell = sheet.cell(row=row_idx, column=col_idx)
value = cell.value
# Convert datetime to ISO format string
if isinstance(value, datetime):
value = value.isoformat()
elif value is None:
value = None
else:
# Keep numbers as numbers, convert others to string
if not isinstance(value, (int, float)):
value = str(value)
row_data[headers[col_idx - 1]] = value
data.append(row_data)
result["sheets"][sheet_name] = {
"dimensions": {
"rows": max_row,
"columns": max_col,
"rows_included": actual_rows
},
"data": data
}
wb.close()
return result
def main():
"""Main entry point for the script."""
if len(sys.argv) < 2:
print("Usage: python xlsx_to_json.py <file_path> [max_rows]")
print("\nExamples:")
print(" python xlsx_to_json.py data.xlsx")
print(" python xlsx_to_json.py data.xlsx 100")
sys.exit(1)
file_path = sys.argv[1]
if not os.path.exists(file_path):
print(f"Error: File not found: {file_path}")
sys.exit(1)
# Parse max rows
max_rows = None
if len(sys.argv) > 2:
try:
max_rows = int(sys.argv[2])
except ValueError:
print(f"Warning: Invalid max_rows value: {sys.argv[2]}")
# Convert to JSON
print(f"Converting {file_path} to JSON...")
data = excel_to_json(file_path, max_rows)
# Output JSON
json_output = json.dumps(data, ensure_ascii=False, indent=2)
print(json_output)
# Summary
print(f"\n# Conversion Summary", file=sys.stderr)
print(f"Total sheets: {data['total_sheets']}", file=sys.stderr)
for sheet_name, sheet_data in data["sheets"].items():
rows = len(sheet_data["data"])
print(f" {sheet_name}: {rows} rows", file=sys.stderr)
if __name__ == "__main__":
main()