z-md-excel
Extract all Markdown tables from a .md file and save them to a formatted Excel .xlsx file.
When to Use
Trigger this skill when the user asks to:
- Convert/extract Markdown tables to Excel
- Export tables from a
.mdfile to.xlsx - Batch extract multiple tables from one Markdown file
- Parse Markdown table data into a spreadsheet
Requirements
- Python 3.7+
- openpyxl:
pip install openpyxl
Usage
Command Line
# Basic usage (output defaults to <input_name>.xlsx)
python scripts/md2xlsx.py input.md
# Specify output file
python scripts/md2xlsx.py input.md output.xlsx
As Agent (recommended workflow)
- Identify the Markdown file the user wants to extract tables from.
- Ensure openpyxl is installed:
pip install openpyxl - Run the script:
python /path/to/z-md-excel/scripts/md2xlsx.py <input.md> [output.xlsx] - Report results: The script prints the number of tables found and their dimensions.
Programmatic (inline Python)
import sys
sys.path.insert(0, '/path/to/z-md-excel/scripts')
from md2xlsx import extract_tables, write_xlsx
tables = extract_tables('input.md')
write_xlsx(tables, 'output.xlsx')
Output Format
- Each table becomes a separate sheet named
Table_1,Table_2, etc. - Header row: Bold white text on blue background, centered
- Data rows: Regular font, auto-fitted column widths
- Alignment: Preserved from Markdown GFM markers (
:---left,:---:center,---:right) - Frozen pane: Top row frozen for easy scrolling
- Inline Markdown stripped: Bold, italic, code, links, images are converted to plain text
How It Works
- Reads the Markdown file line by line
- Detects table blocks (consecutive lines containing
|) - Skips lines inside code blocks (``` fenced blocks)
- Requires a GFM separator row (
|---|---|) to validate a table - Strips inline Markdown formatting from cell content
- Writes all tables to a single Excel file
Limitations
- Only supports GFM-style pipe tables (
| col1 | col2 |) - Does not support HTML
<table>elements - Does not preserve complex Markdown formatting (converts to plain text)
- Nested tables are not supported
File Structure
z-md-excel/
├── SKILL.md # This file (Agent instructions)
├── README.md # Human-readable documentation
└── scripts/
└── md2xlsx.py # Core extraction script