Skip to main content

Embed excel file as an excel-alike table into sphinx documentation.

Project description


The sphinxcontrib-excel-table extension is to render an excel file as an excel-alike table in Sphinx documentation.

This contrib is inspired by sphinxcontrib-excel, which uses pyexcel and handsontable to do the work, but the sphinxcontrib-excel-table will instead use openpyxl and handsontable, mainly to support the following features:

  • merged cell
  • display specific sheet
  • display specific section in one sheet
  • display specific rows in one sheet


You can install it via pip:

$ pip install sphinxcontrib-excel-table

or install it from source code:

$ git clone
$ cd sphinxcontrib-excel-table
$ python install


Add sphinxcontrib.excel_table to your file:

extensions = ['sphinxcontrib.excel_table']

And you need to copy the resource files to your sphinx source directory, the resource files has been installed to your python system path if you install the package via pip, you can copy them from the installation path. You can get the installation path through:

python -c "import sphinxcontrib.excel_table; print sphinxcontrib.excel_table"

for example in Mac:

$ INSTALLATION_PATH=/Library/Python/2.7/site-packages/sphinxcontrib/excel_table/
$ cp $INSTALLATION_PATH/resources/_templates/layout.html path/to/your/project/_templates/
$ cp $INSTALLATION_PATH/resources/_static/handsontable.full.min.js path/to/your/project/_static/
$ cp $INSTALLATION_PATH/resources/_static/handsontable.full.min.css path/to/your/project/_static/

or you can copy the resource files from source code directly.


Here is the syntax to present your excel file in sphinx documentation:

.. excel-table::
   :file: path/to/file.xlsx

This will translate to:

As you can see, it supports merged cells, and this is the mainly goal this contrib will achieve, because other sphinxcontrib excel extensions don’t support this feature, and are not convenient to implement it. The sphinxcontrib-excel-table can do this easily using openpyxl library.


This sphinxcontrib provides the following options:

file (required)

Relative path (based on document) to excel documentation. Note that as openpyxl only supports excel xlsx/xlsm/xltx/xltm files, so this contrib doesn’t support other old excel file formats like xls.

.. excel-table::
   :file: path/to/file.xlsx

sheet (optional)

Specify the name of the sheet to dispaly, if not given, it will default to the first sheet in the excel file.

.. excel-table::
   :file: path/to/file.xlsx
   :sheet: Sheet2

Note this contrib can only display one sheet in one excel-table directive, but you can display different sheet in one excel in different directives.

rows (optional)

Specify the row range of one sheet do display, the default is to display all rows in one sheet, if you use this option, remember to specify a range seperated by a colon.

.. excel-table::
   :file: path/to/file.xlsx
   :rows: 1:10

selection (optional)

Selection defines from and to the selection reaches. If value is not defined, the whole data from sheet is taken into table. And if selection is used, it must specify the from and to range seperated by a colon.

.. excel-table::
   :file: path/to/file.xlsx
   :selection: A1:D10

overflow (optional)

Prevents table to overlap outside the parent element. If ‘horizontal’ option is chosen then table will appear horizontal scrollbar in case where parent’s width is narrower then table’s width. The default is ‘horizontal’, if you want to disable this feature, you can set false to this option.

.. excel-table::
   :file: path/to/file.xlsx
   :overflow: false

colwidths (optional)

Defines column widths in pixels. Accepts number, string (that will be converted to a number), array of numbers (if you want to define column width separately for each column) or a function (if you want to set column width dynamically on each render). The default value is undefined, means the width will be determined by the parent elements.

.. excel-table::
   :file: path/to/file.xlsx
   :colwidths: 100

row_header (optional)

To decide whether to show the row header, the default is true, means to show the row header, you can set this to false to disable the row header.

.. excel-table::
   :file: path/to/file.xlsx
   :row_header: false

col_header (optional)

To decide whether to show the col header, the default is true, means to show the col header, you can set this to false to disable the col header.

.. excel-table::
   :file: path/to/file.xlsx
   :col_header: false

Change log


  • Refactor the code to one folder


  • Add margin bottom to excel table div


  • Add row_header and col_header option to control whether to show the headers


  • Fix bug when openpyxl upgrade to 2.5.2


  • Add python 3 support


  • Fix bug when calls to the same file multiple times chunks the table together
  • Fix bug date NameError when running in Python 3
  • Use the new merged_cells interface of openpyxl


  • Adds the ability to set the table width

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sphinxcontrib-excel-table-enhanced, version 1.0.7
Filename, size File type Python version Upload date Hashes
Filename, size sphinxcontrib_excel_table_enhanced-1.0.7-py3-none-any.whl (163.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page