Convert Excel (XLSX) to Markdown tables
Send an .xlsx workbook to /v1/convert. Each sheet comes back as a heading and one Markdown table.
Last updated
| Output | One '## sheet name' heading and one table per sheet |
|---|---|
| Accepted format | .xlsx (older .xls files are rejected) |
POST /v1/convert converts an Excel workbook (.xlsx) to Markdown in one call. Each sheet becomes a ## <sheet name> heading followed by one Markdown table, in workbook order.
curl
curl -F "file=@figures.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" \
https://api.flatmark.dev/v1/convert
The markdown field of the response:
## Q3
| Region | Revenue | Growth |
| --- | --- | --- |
| EMEA | 412000 | 0.08 |
| APAC | 260500 | NaN |
## Q4
| Region | Revenue |
| --- | --- |
| EMEA | 448900 |
Python: one chunk per sheet
import httpx
XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
with open("figures.xlsx", "rb") as fh:
resp = httpx.post(
"https://api.flatmark.dev/v1/convert",
files={"file": ("figures.xlsx", fh, XLSX)},
headers={"X-API-Key": "YOUR_KEY"}, # optional
timeout=60,
)
resp.raise_for_status()
markdown = resp.json()["markdown"]
sheets = {}
for block in markdown.split("## ")[1:]:
name, _, table = block.partition("\n")
sheets[name.strip()] = table.strip()
for name, table in sheets.items():
print(name, len(table.splitlines()) - 2, "rows")
Check the output
- The first row of each sheet becomes the table header. If a title sits above the real header, remove it before you upload.
- Empty cells come out as
NaN, and empty header cells asUnnamed: 1and so on. - Formulas come out as the values Excel last saved. A formula that was never calculated comes out as
NaN. - Charts, images and formatting are dropped.
Next step
Convert a workbook in the browser, up to 4 MB and without an account.
FAQ
- Does flatmark accept .xls files?
- No. Only .xlsx is accepted, and .xls is rejected with an error (415). Excel, LibreOffice and Google Sheets can save a workbook as .xlsx.
- What happens to empty cells?
- Empty cells come out as NaN. Empty header cells come out as Unnamed: 1, Unnamed: 2 and so on.