문제

What I want is to include an xlsx sheet (or rather the data of said file) into Sphinx documentation.

Is there any way to convert an xlsx sheet to restructuredText?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top