Creating Excel files with Python and XlsxWriter — XlsxWriter Documentation

### Navigation

- index
- next |
- XlsxWriter Documentation »

# Creating Excel files with Python and XlsxWriter

XlsxWriter is a Python module for creating Excel XLSX files.

XlsxWriter supports the following features:

- 100% compatible Excel XLSX files.
- Write text, numbers, formulas, dates.
- Full cell formatting.
- Multiple worksheets.
- Page setup methods for printing.
- Merged cells.
- Defined names.
- Document properties.
- Standard libraries only.
- Python 2/3 support.

Here is a small example:

    from xlsxwriter.workbook import Workbook

    # Create an new Excel file and add a worksheet.
    workbook = Workbook('demo.xlsx')
    worksheet = workbook.add_worksheet()

    # Widen the first column to make the text clearer.
    worksheet.set_column('A:A', 20)

    # Add a bold format to highlight cell text.
    bold = workbook.add_format({'bold': 1})

    # Write some simple text.
    worksheet.write('A1', 'Hello')

    # Text with formatting.
    worksheet.write('A2', 'World', bold)

    # Write some numbers, with row/column notation.
    worksheet.write(2, 0, 123)
    worksheet.write(3, 0, 123.456)

    workbook.close()

Which generates a worksheet like this:

This document explains how to install and use the XlsxWriter module.

- Contents

- Introduction
- Getting Started with XlsxWriter
- Tutorial 1: Create a simple XLSX file
- Tutorial 2: Adding formatting to the XLSX File
- Tutorial 3: Writing different types of data to the XLSX File
- The Workbook Class
- The Worksheet Class
- The Worksheet Class (Page Setup)
- The Format Class
- Working with Cell Notation
- Working with Formats
- Working with Dates and Time
- Examples
- Excel::Writer::XLSX
- Alternative modules for handling Excel files
- Known Issues and Bugs
- Reporting Bugs
- Frequently Asked Questions
- Changes in XlsxWriter
- Author
- License

### Navigation

- index
- next |
- XlsxWriter Documentation »