Sphinx: include xlsx data into rst

You do not need to convert it to rst. If you export your xlsx sheet to a comma separated file (csv) you can then use the csv-table directive.

The great thing is that you need to set up your table in your csv only once, and whenever you update your xlsx sheet, just export again to csv to the same location of where your table was before.

.. csv-table:: The contents of my xlsx sheet exported to mytable.csv
   :widths: 15 40 20
   :header: "Header 1", "Header 2", "Header 3"
   :file: mytable.csv

That is all. Add as many widths and headers as you have columns in your file.

Note that in the documentation a security warning is given when using the :file: option. You can choose to copy paste the comma separated text into the document. However, if you update the table regularly I find it easiest to just export again to csv.


I have just released sphinxcontrib-excel, which embeds xlsx, xls and ods data (without style, font, charts) into your sphinx documentation. And you do not need to convert from xlsx to csv because the library does it for it.

Here is an example page where it was used to render excel data in readthedocs.org directly.