Skip to main content

Excel VBAを解析し仕様書を生成するCLIツール

Project description

XLSM2Spec

Excel VBAを解析し仕様書を自動生成するCLIツール

Python License

概要

XLSM2Specは、ExcelファイルのVBAマクロを解析し、構造化された仕様書を自動生成します。 レガシーシステムの保守・移行プロジェクトにおいて、既存のExcelマクロの動作理解を支援します。

機能

  • ✅ xls/xlsx/xlsm ファイルの読み込み
  • ✅ VBAコードの抽出と解析
  • ✅ モジュール・プロシージャ構造の解析
  • ✅ Markdown/JSON/HTML形式での仕様書出力

インストール

pip install xlsm2spec

または開発版:

git clone https://github.com/your-org/xlsm2spec.git
cd xlsm2spec
pip install -e ".[dev]"

使い方

基本的な使い方

# Excelファイルを解析し、仕様書を標準出力に表示
xlsm2spec analyze sample.xlsm

# 仕様書をファイルに出力
xlsm2spec analyze sample.xlsm -o spec.md

# JSON形式で出力
xlsm2spec analyze sample.xlsm -o spec.json -f json

# HTML形式で出力(スタイル付き)
xlsm2spec analyze sample.xlsm -o spec.html -f html

# 詳細ログを表示
xlsm2spec analyze sample.xlsm --verbose

コマンドオプション

Usage: xlsm2spec analyze [OPTIONS] INPUT_FILE

  ExcelファイルのVBAを分析し、仕様書を生成する

Arguments:
  INPUT_FILE  分析するExcelファイル (.xls, .xlsx, .xlsm)  [required]

Options:
  -o, --output PATH     出力ファイルパス(省略時は標準出力)
  -f, --format TEXT     出力形式(markdown, json, html)  [default: markdown]
  --verbose             詳細な出力を表示
  --help                Show this message and exit.

出力例

# sample.xlsm 仕様書

**生成日時**: 2025-12-12 10:00:00

## シート一覧
- Sheet1
- Sheet2

## VBAモジュール一覧

| モジュール名 | 種別 | プロシージャ数 |
|-------------|------|--------------|
| Module1 | standard | 2 |

### Module1

**種別**: standard

#### プロシージャ一覧

##### CalculateTotal

- **種別**: function
- **アクセス**: Public
- **引数**: startRow: Long, endRow: Long
- **戻り値**: Double

開発

環境構築

# 仮想環境作成
python -m venv .venv
source .venv/bin/activate  # Linux/macOS
# .venv\Scripts\activate   # Windows

# 開発版インストール
pip install -e ".[dev]"

# テスト実行
pytest

# 型チェック
mypy src/

# リンター
ruff check src/

プロジェクト構造

xlsm2spec/
├── src/xlsm2spec/
│   ├── domain/          # ドメインモデル(Workbook, Module, Procedure等)
│   ├── application/     # アプリケーションサービス(AnalyzerService)
│   ├── infrastructure/  # 外部ライブラリ統合(ExcelReader, VbaExtractor, VbaParser)
│   └── presentation/    # 出力フォーマッター(Markdown, JSON, HTML)
├── tests/               # pytest テスト
└── steering/            # MUSUBI SDD ドキュメント

アーキテクチャ

Clean Architecture(4層構造)を採用:

  • Domain層: ビジネスモデル(Workbook, VbaProject, Module, Procedure)
  • Application層: ユースケース(AnalyzerService)
  • Infrastructure層: 外部ライブラリ統合(xlrd, openpyxl, oletools)
  • Presentation層: 出力フォーマット(Markdown, JSON, HTML)

ライセンス

MIT License

貢献

Issue、Pull Requestを歓迎します。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlsm2spec-0.1.0.tar.gz (135.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xlsm2spec-0.1.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file xlsm2spec-0.1.0.tar.gz.

File metadata

  • Download URL: xlsm2spec-0.1.0.tar.gz
  • Upload date:
  • Size: 135.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for xlsm2spec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ccf86a8b5fbd7ce06110ba1c9ea1613f4f30273417ab8c44232c5fe8be0af545
MD5 9e85486e6752fda14008515fd5cff458
BLAKE2b-256 e5b43de457d3918bd0f069b4dadc9848df45a9a7b1c166cbd11cd2c5a7ba7d47

See more details on using hashes here.

File details

Details for the file xlsm2spec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xlsm2spec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for xlsm2spec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00c0e969810df45824277263e64a90dd86092917048576af94295cb9f9a11c27
MD5 b77b7bf673f2f87f7d4e19b686385e12
BLAKE2b-256 31790a097097679c6a15d16bfef9585262faeaad302c237dd9a74d394904fb9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page