Formats
Converting Excel workbooks to Markdown with MarkItDown
MarkItDown turns every sheet into one Markdown table, reading the workbook the way a data library would, not the way Excel displays it. That is why blanks become NaN and percentages become decimals. We built 17 test workbooks, one per behaviour, and recorded what each one produced on version 0.1.9.
Short answer
Install the extra (xlsx, plus xls for old .xls files), convert, save with -o:
markitdown workbook.xlsx -o workbook.mdOne table per sheet, values not formulas, no formatting, blanks as NaN. Clean it with the recipe below.
Tested with markitdown 0.1.9 · Python 3.13 · markitdown[all] 0.1.9 · Linux lab (LibreOffice 24.2 for recalculation and legacy formats); the sample workbooks also ran on Windows, macOS and Ubuntu runners (T05) · 2026-11-15 · evidence: office-features.csv, xlsx-number-formats.csv, xlsx-scale.csv, xlsx-features.jsonl
What a workbook becomes
Our three-sheet sample workbook:
## Rainfall
| Station | Date | Rainfall (mm) | Cost | Share |
| --- | --- | --- | --- | --- |
| Alpha | 2026-03-01 | 412.5 | 1200.50 | 0.33 |
| Bravo | 2026-03-02 | 388.0 | 980.00 | 0.31 |
| Charlie | 2026-03-03 | 451.3 | 1410.25 | 0.36 |
| NaN | NaT | NaN | NaN | NaN |
| Total | NaT | 1251.8 | 3590.75 | NaN |
## Notes
| Merged header across three columns | Unnamed: 1 | Unnamed: 2 |
| --- | --- | --- |
| Key | Value | Comment |
| battery | low | NaN |
| NaN | NaN | NaN |
| sensor | new | pipe | inside |
## Empty
|
| |Rainfall
| Station | Date | Rainfall (mm) | Cost | Share |
|---|---|---|---|---|
| Alpha | 2026-03-01 | 412.5 | 1200.50 | 0.33 |
| Bravo | 2026-03-02 | 388.0 | 980.00 | 0.31 |
| Charlie | 2026-03-03 | 451.3 | 1410.25 | 0.36 |
| NaN | NaT | NaN | NaN | NaN |
| Total | NaT | 1251.8 | 3590.75 | NaN |
Notes
| Merged header across three columns | Unnamed: 1 | Unnamed: 2 |
|---|---|---|
| Key | Value | Comment |
| battery | low | NaN |
| NaN | NaN | NaN |
| sensor | new | pipe |
Empty
| | |
Look for: one ## SheetName heading per sheet; the first row used as the header; NaN and NaT for blank cells; Unnamed: 1 for blank header cells; decimals where Excel showed a percentage or currency; and an empty sheet that still produces a heading and a stray empty table.
Feature by feature
| Behaviour | Result | What came out | Note |
|---|---|---|---|
| Several sheets | kept | ## Rainfall↵| Station | mm |↵| --- | --- |↵| Alpha | 412.5 |↵↵## Notes↵| Key | Value |↵| --- | --- |↵| battery | low | | One ## heading per sheet. |
| Empty sheet | changed | ## Data↵| A | B |↵| --- | --- |↵| 1 | 2 |↵↵## EmptySheet↵|↵| |↵↵## HiddenSheet↵| secret |↵| --- |↵| hidden value | | An empty sheet produces a heading with an empty table. |
| Hidden sheet | changed | ## HiddenSheet↵| secret |↵| --- |↵| hidden value | | Hidden sheets are included in the output. |
| Hidden rows and columns | changed | ## Sheet↵| A | B | C |↵| --- | --- | --- |↵| 1 | 2 | 3 |↵| hiddenrow | x | y | | Hidden rows and columns are included. |
| Formulas without cached results | lost | ## Sheet↵| x | double |↵| --- | --- |↵| 2 | NaN |↵| 3 | NaN |↵| total | NaN | | Formula cells come out as NaN: the formula text is never output. |
| Formulas after re-saving through LibreOffice | kept | ## Sheet↵| x | double |↵| --- | --- |↵| 2 | 4 |↵| 3 | 6 |↵| total | 10 | | Results are present after a recalculation pass. |
| Number formats (see table below) | changed | ## Sheet↵| Case | Value shown in Excel |↵| --- | --- |↵| date | 2026-03-01 00:00:00 |↵| datetime | 2026-03-01 14:30:00 |↵| time | 09:15:00 |↵| currency | 1200.5 |↵| percent | 0.331 |↵| thousands | 1234567 |↵| zip code as text | 01 | Excel's display formats are not applied. |
| Merged header cells | changed | ## Sheet↵| Merged header across three columns | Unnamed: 1 | Unnamed: 2 |↵| --- | --- | --- |↵| Key | Value | Comment |↵| battery | low | NaN | | Merged cells give Unnamed columns; the real header becomes the first data row. |
| Header on row 3 or below | changed | ## Sheet↵| Report title | Unnamed: 1 |↵| --- | --- |↵| Generated 2026-03-01 | NaN |↵| NaN | NaN |↵| Station | mm |↵| Alpha | 412.5 | | The first row is used as the header, so the real header becomes data. |
| Blank spacer rows and columns | changed | ## Sheet↵| A | Unnamed: 1 | C |↵| --- | --- | --- |↵| 1.0 | NaN | 3.0 |↵| NaN | NaN | NaN |↵| 4.0 | NaN | 6.0 | | Blanks become NaN and Unnamed columns; the table is not split. |
| A pipe and a line break inside cells | changed | ## Sheet↵| k | v |↵| --- | --- |↵| state | OK | stable |↵| note | line one\nline two | | A pipe is NOT escaped, so the row gets an extra cell; a line break inside a cell comes out as the two characters \n. |
| Wide sheet (60 columns) | kept | ## Sheet↵| col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 | col13 | col14 | col15 | col16 | col17 | col18 | col19 | col20 | col21 | col22 | col23 | col24 | col25 | col26 | col27 | col28 | col2 | One very long table row; readable by a model, not by a person. |
| Chart, picture and cell note | lost | ## Sheet↵| Quarter | Revenue |↵| --- | --- |↵| Q1 | 10 |↵| Q2 | 14 |↵| Q3 | 9 | | Only the cell values are output; chart, picture and note are ignored. |
| Integers next to a blank cell | changed | ## Sheet↵| id | count |↵| --- | --- |↵| 1 | 5.0 |↵| 2 | NaN |↵| 3 | 7.0 | | A column with a blank is read as floating point, so 5 prints as 5.0. |
| .xls (legacy workbook) | kept | ## Rainfall↵| Station | mm |↵| --- | --- |↵| Alpha | 412.5 |↵↵## Notes↵| Key | Value |↵| --- | --- |↵| battery | low | | Handled by the xls extra; the output matches the .xlsx. |
| .xlsm (macro-enabled extension) | kept | ## Rainfall↵| Station | mm |↵| --- | --- |↵| Alpha | 412.5 |↵↵## Notes↵| Key | Value |↵| --- | --- |↵| battery | low | | Accepted only if the extension is recognised; see the output. |
| .ods (OpenDocument spreadsheet): directly and through LibreOffice | kept | directly: UnsupportedFormatException: Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filet | via .xlsx: ## Rainfall↵| Station | mm |↵| --- | --- |↵| Alpha | 412.5 |↵↵## Notes↵| Key | Value |↵| --- | --- | | Directly: refused. Through LibreOffice to .xlsx: identical to converting the original. |
| .ods (OpenDocument spreadsheet) | lost | UnsupportedFormatException: Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filetype is simply not supported. | No converter for .ods. |
Why you see NaN, NaT and Unnamed
Where they come from
The sheet is loaded as a data frame (pandas) and written out as a table. Missing numbers are NaN, missing dates are NaT and missing header cells are named Unnamed: n. MarkItDown 0.1.9 has no option to change that.
Integers that turn into decimals
A column with a blank cell is read as floating point, so 5 prints as 5.0 and the blank as NaN:
## Sheet
| id | count |
| --- | --- |
| 1 | 5.0 |
| 2 | NaN |
| 3 | 7.0 |Sheet
| id | count |
|---|---|
| 1 | 5.0 |
| 2 | NaN |
| 3 | 7.0 |
The clean-up recipe
Post-process the output: blank NaN/NaT, blank the Unnamed headers and drop rows that are completely empty. It cannot tell a literal cell containing the text "NaN" from a missing one, so do not use it on data where that matters.
import re
from markitdown import MarkItDown
def clean(markdown: str) -> str:
"""Blank NaN/NaT cells, rename 'Unnamed: n' headers to nothing, drop rows that are completely empty."""
out = []
for line in markdown.splitlines():
if line.startswith("|") and not line.startswith("| ---"):
cells = [c.strip() for c in line.strip().strip("|").split(" | ")]
cells = ["" if c in ("NaN", "NaT") or re.fullmatch(r"Unnamed: \d+", c) else c for c in cells]
if not any(cells):
continue
line = "| " + " | ".join(cells) + " |"
out.append(line)
return "\n".join(out)
raw = MarkItDown().convert("samples/xlsx-blank-rows-cols.xlsx").markdown
print("BEFORE\n" + raw)
print("AFTER\n" + clean(raw))BEFORE
## Sheet
| A | Unnamed: 1 | C |
| --- | --- | --- |
| 1.0 | NaN | 3.0 |
| NaN | NaN | NaN |
| 4.0 | NaN | 6.0 |
AFTER
## Sheet
| A | | C |
| --- | --- | --- |
| 1.0 | | 3.0 |
| 4.0 | | 6.0 | The alternative: read the sheet yourself
When you control the code, loading the sheet yourself is cleaner than repairing the output. This is outside MarkItDown; it needs pandas and tabulate.
import pandas as pd
# when you control the code, read the sheet yourself: choose the header row, keep blanks as empty strings, then write the table
df = pd.read_excel("samples/xlsx-header-row3.xlsx", header=3, dtype=str).fillna("")
print(df.to_markdown(index=False))| Station | mm |
|:----------|------:|
| Alpha | 412.5 | Formulas: you get the last calculated value, or nothing
A workbook saved by Excel carries a cached result for each formula, and MarkItDown outputs that value, never the formula text. A workbook written by a script and never opened in Excel has no cached results, and every formula cell comes out as NaN:
## Sheet
| x | double |
| --- | --- |
| 2 | NaN |
| 3 | NaN |
| total | NaN |Sheet
| x | double |
|---|---|
| 2 | NaN |
| 3 | NaN |
| total | NaN |
The tested fix is to recalculate and re-save through LibreOffice in headless mode, then convert; the same file then gave 4, 6 and 10:
## Sheet
| x | double |
| --- | --- |
| 2 | 4 |
| 3 | 6 |
| total | 10 |Sheet
| x | double |
|---|---|
| 2 | 4 |
| 3 | 6 |
| total | 10 |
Error values such as #DIV/0! come out as NaN.
Dates, currency, percentages and other number formats
Excel's display formats are not applied. This is what each case produced (the workbook had been saved by LibreOffice so that the values were cached):
| Case | Shown in Excel | MarkItDown output | Verdict |
|---|---|---|---|
| date | 01/03/2026 (format dd/mm/yyyy) | 2026-03-01 00:00:00 | Changed: ISO date with a 00:00:00 time |
| datetime | 2026-03-01 14:30 | 2026-03-01 14:30:00 | Changed: seconds added |
| time | 09:15 | 09:15:00 | Changed: seconds added |
| currency | $1,200.50 | 1200.5 | Lost: symbol and separators |
| percent | 33.1% | 0.331 | Lost: becomes the fraction 0.331 |
| thousands | 1,234,567 | 1234567 | Lost: separators |
| zip code as text | 01234 | 01234 | Kept: text keeps its zero |
| zip code as number with leading zero format | 01234 (format 00000) | 1234 | Lost: the leading zero (1234) |
| scientific | 1.23E-04 | 0.000123 | Lost: plain decimal |
| very long number | 12345678901234567890 | 12345678901234599936 | Changed: precision lost (…4599936) |
| boolean | TRUE | True | Changed: True |
| error value | #DIV/0! | NaN | Lost: NaN instead of the error |
The dangerous ones are the leading zero (01234 stored as a number with a display format becomes 1234: store codes as text) and the very long number, which lost precision.
Layouts that confuse the table
- Merged header cells: the merged title becomes the header and the real header becomes the first row.
## Sheet
| Merged header across three columns | Unnamed: 1 | Unnamed: 2 |
| --- | --- | --- |
| Key | Value | Comment |
| battery | low | NaN |Sheet
| Merged header across three columns | Unnamed: 1 | Unnamed: 2 |
|---|---|---|
| Key | Value | Comment |
| battery | low | NaN |
- Header not on the first row: title rows above the table become the header. Mitigation: read the sheet yourself with the right header row (above).
## Sheet
| Report title | Unnamed: 1 |
| --- | --- |
| Generated 2026-03-01 | NaN |
| NaN | NaN |
| Station | mm |
| Alpha | 412.5 |Sheet
| Report title | Unnamed: 1 |
|---|---|
| Generated 2026-03-01 | NaN |
| NaN | NaN |
| Station | mm |
| Alpha | 412.5 |
- Blank rows and columns: they stay inside the table as
NaNandUnnamedcolumns; the table is not split. The recipe above removes them. - A
|inside a cell is not escaped and adds a column; a line break inside a cell comes out as the two characters\n.
## Sheet
| k | v |
| --- | --- |
| state | OK | stable |
| note | line one\nline two |Sheet
| k | v |
|---|---|
| state | OK |
| note | line one\nline two |
- Wide sheets: 60 columns gave one very long row, which a model can read and a person cannot.
- Hidden sheets, rows and columns are included. A sheet with
state=hiddenappeared in the output with its data. - An empty sheet produces a heading and a stray empty table.
Charts, pictures, comments and pivot tables
Only cell values are output. A bar chart, a picture and a cell note on one sheet all disappeared from the output (unlike PowerPoint, where charts become tables: PowerPoint page). Pictures are covered on the image page. We did not test pivot tables.
.xls, .xlsm, .xlsb and .ods
.xlsneeds thexlsextra and gave the same output as.xlsxfor our workbook..xlsm(an.xlsxrenamed, with no macros inside) was accepted. We did not test a file that really contains macros; macros are never run..odsraisedUnsupportedFormatException: no converter..xlsb: we did not test it.
UnsupportedFormatException: Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filetype is simply not supported.UnsupportedFormatException: Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filetype is simply not supported.
Big workbooks: time, memory and output size
Workbooks of 10 columns and 1,000 to 100,000 rows on our lab machine:
| Rows | File (MB) | Seconds | Peak memory (MB) | Output (characters) | Tokens |
|---|---|---|---|---|---|
| 1000 | 0.05 | 0.8 | 178 | 65963 | 34389 |
| 10000 | 0.44 | 7.1 | 333 | 717297 | 385389 |
| 50000 | 2.18 | 36.5 | 1027 | 3837297 | |
| 100000 | 4.37 | 74.7 | 1900 | 7770631 |
Time and memory grow roughly in step with the row count: 100,000 rows took 75 seconds and 1.9 GB. A 4 MB workbook becomes 7.8 million characters of Markdown, far more than any model reads, so convert only the sheets and rows you need. We did not reproduce the upstream report of a 102 MB workbook that never finished, because we did not generate a file of that size.
Convert one sheet, or a range
There is no sheet-selection option on the command line. Split the output on the ## headings:
from markitdown import MarkItDown
markdown = MarkItDown().convert("samples/xlsx-sheets.xlsx").markdown
sheets = {}
for block in markdown.split("\n## ")[0:]:
block = block.removeprefix("## ")
name, _, body = block.partition("\n")
sheets[name.strip()] = body.strip()
print(list(sheets))
print(sheets["Notes"])['Rainfall', 'Notes']
| Key | Value |
| --- | --- |
| battery | low | Errors specific to Excel files
XlsxConverter threw MissingDependencyException means the xlsx extra is missing, and the legacy equivalent is XlsConverter (xls extra); see the missing-dependency page. We did not test corrupt or password-protected workbooks.
Version notes
The xlsx and xls converters arrived as extras in since 0.1.0, when all optional dependencies were split out (extras). We did not find other spreadsheet changes in the release notes we read.