Xlsx to Md

Use GroupDocs.Markdown to convert XLSX and other spreadsheet files to Markdown tables. You can control how many columns and rows are included using spreadsheet-specific options.

Using static method

The simplest way to convert a spreadsheet file:

import os
from groupdocs.markdown import License, MarkdownConverter

def export_spreadsheet_to_markdown():
    """Convert an Excel spreadsheet to Markdown using the static one-liner API."""

    # Step 1: Apply the license (optional for evaluation)
    if os.path.exists("GroupDocs.Markdown.lic"):
        License.set_("GroupDocs.Markdown.lic")

    # Step 2: Convert XLSX to a Markdown string in one call
    markdown = MarkdownConverter.to_markdown("cost-analysis.xlsx")

    # Step 3: Or save the conversion result directly to a file
    MarkdownConverter.to_file("cost-analysis.xlsx", "export-spreadsheet.md")

if __name__ == "__main__":
    export_spreadsheet_to_markdown()

cost-analysis.xlsx is sample file used in this example. Click here to download it.

## Cost data and chart

|  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
|  |  | Cost Analysis |  |  |  |  |  |
|  |  | PARETO CHART |  |  |  |  |  |
|  |  | COST ANALYSIS |  |  |  |  | COST CENTER |
|  |  | Cost center | Annual cost  | Percent of total | Cumulative percent |  |  |
|  |  | Parts and materials | $1,325,000.00  | 31.17% | 31.17% |  |  |
|  |  | Manufacturing equipment | $900,500.00  | 21.19% | 52.36% |  |  |
...

Download full output

## Cost data and chart

|  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
|  |  | Cost Analysis |  |  |  |  |  |
|  |  | PARETO CHART |  |  |  |  |  |
|  |  | COST ANALYSIS |  |  |  |  | COST CENTER |
|  |  | Cost center | Annual cost  | Percent of total | Cumulative percent |  |  |
|  |  | Parts and materials | $1,325,000.00  | 31.17% | 31.17% |  |  |
|  |  | Manufacturing equipment | $900,500.00  | 21.19% | 52.36% |  |  |
[TRUNCATED]

Download full output

Using instance API with options

For more control, use the instance API. The ConvertOptions class provides spreadsheet-specific properties such as max_columns and max_rows to limit the size of the exported tables:

import os
from groupdocs.markdown import License, MarkdownConverter, ConvertOptions

def export_spreadsheet_with_options():
    """Convert an Excel spreadsheet to Markdown with column/row limits and heading offset."""

    # Step 1: Apply the license (optional for evaluation)
    if os.path.exists("GroupDocs.Markdown.lic"):
        License.set_("GroupDocs.Markdown.lic")

    # Step 2: Open the spreadsheet with a context manager
    with MarkdownConverter("cost-analysis.xlsx") as converter:
        # Step 3: Configure spreadsheet-specific conversion options
        options = ConvertOptions()
        options.max_columns = 10   # limit to first 10 columns
        options.max_rows = 100     # limit to first 100 data rows per sheet
        options.heading_level_offset = 1  # shift headings down one level

        # Step 

        # Step 4: Convert and save the Markdown output
        converter.convert("export-spreadsheet-options.md", convert_options=options)

if __name__ == "__main__":
    export_spreadsheet_with_options()

cost-analysis.xlsx is sample file used in this example. Click here to download it.

## Cost data and chart

|  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
|  |  | Cost Analysis |  |  |  |  |  |
|  |  | PARETO CHART |  |  |  |  |  |
|  |  | COST ANALYSIS |  |  |  |  | COST CENTER |
|  |  | Cost center | Annual cost  | Percent of total | Cumulative percent |  |  |
|  |  | Parts and materials | $1,325,000.00  | 31.17% | 31.17% |  |  |
|  |  | Manufacturing equipment | $900,500.00  | 21.19% | 52.36% |  |  |
...

Download full output

## Cost data and chart

|  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
|  |  | Cost Analysis |  |  |  |  |  |
|  |  | PARETO CHART |  |  |  |  |  |
|  |  | COST ANALYSIS |  |  |  |  | COST CENTER |
|  |  | Cost center | Annual cost  | Percent of total | Cumulative percent |  |  |
|  |  | Parts and materials | $1,325,000.00  | 31.17% | 31.17% |  |  |
|  |  | Manufacturing equipment | $900,500.00  | 21.19% | 52.36% |  |  |
[TRUNCATED]

Download full output

For the full list of input formats, see the supported formats page.