Skip to main content

A sphinx extension for making table from Excel file

Project description

A sphinx extension for making table from Excel file.

  • Depends on OpenPyXL
    • Supports xlsx file
  • Supports merged cell
  • Supports Japanese

This extension generates a grid table string internally from Excel file.

Install and Set up

Install from PyPI.

$ pip install sphinxcontrib-xlsxtable

Configure conf.py

# conf.py
extensions = [
    'sphinxcontrib.xlsxtable',
]

Usage

reStructuredText directive:

.. xlsx-table:: Table Caption
   :file: path/to/xlsx/file.xlsx
   :header-rows: 1

Excel file:

https://raw.githubusercontent.com/kkAyataka/sphinxcontrib-xlsxtable/master/sample-excel.png

Rendered HTML:

https://raw.githubusercontent.com/kkAyataka/sphinxcontrib-xlsxtable/master/sample-rendering.png

Options

Caption (optional)

Specifies table caption string.

.. xlsx-table:: Table Caption
   :file: path/to/xlsx/file.xlsx

:file: (required)

Specifies path to Excel file. You can use relative path.

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

:header-rows: (optional)

Specified the number of lines are used as header.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :header-rows: 1

:sheet: (optional)

Generates a table from a sheet with the specified sheet name.

If this option is not specified, current active sheet is used.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :sheet: Sheet1

:start-row: (optional)

Specifies start row number.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :start-row: 2

:start-column: (optional)

Specifies start column number.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :start-column: 2

:include-rows: / :exclude-rows: (optional)

Specifies include or exclude rows. Exclude setting has priority.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :include-rows: 1-2 4 8
   :exclude-rows: 3 5-7

:include-columns: / :exclude-columns: (optional)

Specifies include or exclude columns. Exclude setting has priority.

.. xlsx-table::
   :file: path/to/xlsx/file.xlsx
   :include-columns: A-B 4
   :exclude-columns: C 5-6

CLI

You can use from CLI.

$ python -m sphinxcontrib.xlsxtable --sheet=Sheet1 --header-rows=1 test/_res/sample.xlsx
+----+-------+-------+--------+
| A1 | B1    | C1    | D1     |
+====+=======+=======+========+
| A2 | B2:B3 | C2    | D2     |
+----+       +-------+--------+
| A3 |       | C3:D3          |
+----+-------+-------+--------+
| A4 | B4    | C4    | - D4-1 |
|    |       |       | - D4-2 |
+----+-------+-------+--------+

LICENSE

  • MIT

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-xlsxtable, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size sphinxcontrib_xlsxtable-1.0.0-py3-none-any.whl (8.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size sphinxcontrib-xlsxtable-1.0.0.tar.gz (7.9 kB) File type Source Python version None Upload date Hashes View

Supported by

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