> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/microsoft/markitdown/llms.txt
> Use this file to discover all available pages before exploring further.

# XlsxConverter & XlsConverter

> Convert Excel spreadsheets to Markdown tables with support for multiple sheets

## Overview

MarkItDown provides two converters for Excel files:

* `XlsxConverter` - For modern Excel files (`.xlsx`, Excel 2007+)
* `XlsConverter` - For legacy Excel files (`.xls`, Excel 97-2003)

Both converters extract data from all sheets and present each as a separate Markdown table.

## Dependencies

<CodeGroup>
  ```bash pip (XLSX) theme={null}
  pip install markitdown[xlsx]
  ```

  ```bash pip (XLS) theme={null}
  pip install markitdown[xls]
  ```

  ```bash uv (XLSX) theme={null}
  uv pip install markitdown[xlsx]
  ```

  ```bash uv (XLS) theme={null}
  uv pip install markitdown[xls]
  ```
</CodeGroup>

**XLSX requires:** `pandas`, `openpyxl`\
**XLS requires:** `pandas`, `xlrd`

## XlsxConverter

### Accepted Formats

<ParamField path="MIME Types" type="list">
  * `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
</ParamField>

<ParamField path="Extensions" type="list">
  * `.xlsx`
</ParamField>

### Class Definition

```python theme={null}
class XlsxConverter(DocumentConverter):
    """Converts XLSX files to Markdown.
    
    Each sheet presented as a separate Markdown table.
    """
```

### Constructor

```python theme={null}
def __init__(self):
    super().__init__()
    self._html_converter = HtmlConverter()
```

### Methods

#### accepts()

```python theme={null}
def accepts(
    file_stream: BinaryIO,
    stream_info: StreamInfo,
    **kwargs: Any,
) -> bool
```

Returns `True` for `.xlsx` files.

#### convert()

```python theme={null}
def convert(
    file_stream: BinaryIO,
    stream_info: StreamInfo,
    **kwargs: Any,
) -> DocumentConverterResult
```

Converts an XLSX file to Markdown.

**Returns:** `DocumentConverterResult` with all sheets as Markdown tables

**Raises:** `MissingDependencyException` if dependencies not installed

### Example Usage

```python theme={null}
from markitdown.converters import XlsxConverter
from markitdown._stream_info import StreamInfo

converter = XlsxConverter()

with open("spreadsheet.xlsx", "rb") as f:
    stream_info = StreamInfo(extension=".xlsx")
    result = converter.convert(f, stream_info)
    print(result.markdown)
```

### Output Example

```markdown theme={null}
## Sheet1

| Name | Age | City |
| --- | --- | --- |
| Alice | 30 | New York |
| Bob | 25 | San Francisco |
| Charlie | 35 | Chicago |

## Sheet2

| Product | Price | Stock |
| --- | --- | --- |
| Widget A | 19.99 | 100 |
| Widget B | 29.99 | 50 |
```

## XlsConverter

### Accepted Formats

<ParamField path="MIME Types" type="list">
  * `application/vnd.ms-excel`
  * `application/excel`
</ParamField>

<ParamField path="Extensions" type="list">
  * `.xls`
</ParamField>

### Class Definition

```python theme={null}
class XlsConverter(DocumentConverter):
    """Converts XLS files to Markdown.
    
    Each sheet presented as a separate Markdown table.
    """
```

### Constructor

```python theme={null}
def __init__(self):
    super().__init__()
    self._html_converter = HtmlConverter()
```

### Methods

#### accepts()

```python theme={null}
def accepts(
    file_stream: BinaryIO,
    stream_info: StreamInfo,
    **kwargs: Any,
) -> bool
```

Returns `True` for `.xls` files.

#### convert()

```python theme={null}
def convert(
    file_stream: BinaryIO,
    stream_info: StreamInfo,
    **kwargs: Any,
) -> DocumentConverterResult
```

Converts an XLS file to Markdown.

**Returns:** `DocumentConverterResult` with all sheets as Markdown tables

**Raises:** `MissingDependencyException` if dependencies not installed

### Example Usage

```python theme={null}
from markitdown.converters import XlsConverter
from markitdown._stream_info import StreamInfo

converter = XlsConverter()

with open("legacy_file.xls", "rb") as f:
    stream_info = StreamInfo(extension=".xls")
    result = converter.convert(f, stream_info)
    print(result.markdown)
```

## Implementation Details

### Source Location

`~/workspace/source/packages/markitdown/src/markitdown/converters/_xlsx_converter.py`

* `XlsxConverter`: Line 36
* `XlsConverter`: Line 98

### Conversion Pipeline

Both converters use the same process:

1. **Read All Sheets** - Load all worksheets using pandas
   ```python theme={null}
   sheets = pd.read_excel(file_stream, sheet_name=None, engine="openpyxl")
   ```

2. **Convert to HTML** - Each sheet converted to HTML table
   ```python theme={null}
   html_content = sheets[sheet_name].to_html(index=False)
   ```

3. **HTML to Markdown** - HTML table converted to Markdown
   ```python theme={null}
   md_content = self._html_converter.convert_string(html_content)
   ```

4. **Combine Sheets** - All sheets joined with H2 headers

### Sheet Headers

Each sheet is prefixed with an H2 heading using the sheet name:

```markdown theme={null}
## SheetName
```

## Features

### Supported Elements

* **Data Types** - Numbers, text, dates, booleans
* **Multiple Sheets** - All sheets included with headers
* **Formulas** - Evaluated values shown (not formula text)
* **Merged Cells** - Handled by pandas

### Data Handling

* **Index Column** - Not included (`index=False`)
* **Column Names** - First row used as header
* **Missing Values** - Empty cells rendered as empty table cells
* **Formatting** - Cell formatting (colors, fonts) not preserved

## Limitations

* Charts and images not extracted
* Cell styling and colors not preserved
* Formulas shown as values, not expressions
* Macros and VBA code not included
* Multiple tables per sheet may merge
* Conditional formatting not preserved
* Comments and notes not extracted

## Performance Considerations

* Entire workbook loaded into memory
* Large spreadsheets may require significant RAM
* Processing time scales with number of sheets and cells
