Spreadsheet conversion options

When converting spreadsheets, use these properties on ConvertOptions to control the Markdown table output.

Column and row truncation

from groupdocs.markdown import MarkdownConverter, ConvertOptions

def spreadsheet_truncation():
    """Convert a spreadsheet with column and row truncation limits."""

    # Step 1: Configure column and row limits
    options = ConvertOptions()
    options.max_columns = 8     # only include the first 8 columns
    options.max_rows = 50       # only include the first 50 data rows per sheet

    # Step 2: Convert with truncation options using keyword argument
    md = MarkdownConverter.to_markdown("cost-analysis.xlsx", convert_options=options)

    # Truncated columns/rows show "..." indicators.
    # Warnings are reported in ConvertResult.warnings.

if __name__ == "__main__":
    spreadsheet_truncation()

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

Sheet separator and hidden sheets

from groupdocs.markdown import MarkdownConverter, ConvertOptions

def spreadsheet_sheets():
    """Convert a workbook with custom sheet separators and hidden sheet filtering."""

    # Step 1: Configure sheet separator and hidden sheet behavior
    options = ConvertOptions()
    options.sheet_separator = "\n---\n"      # horizontal rule between worksheets
    options.include_hidden_sheets = False    # skip hidden worksheets (default)

    # Step 2: Open the workbook with a context manager
    with MarkdownConverter("cost-analysis.xlsx") as converter:
        # Step 3: Convert using keyword argument for options
        result = converter.convert(convert_options=options)

        # Step 4: Check for conversion warnings (e.g., truncation)
        for warning in result.warnings:
            print(f"Warning: {warning}")
        # e.g. "Worksheet 'Data' truncated at 50 rows."

if __name__ == "__main__":
    spreadsheet_sheets()

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

Available options

PropertyTypeDefaultDescription
max_columnsint0 (unlimited)Maximum columns per table
max_rowsint0 (unlimited)Maximum data rows per worksheet
sheet_separatorstr"\n---\n"Separator inserted between worksheets
include_hidden_sheetsboolFalseWhether to include hidden worksheets