Skip to main content

Status Documentation Status

Documentation here: https://xltable.readthedocs.org/en/latest

xltable is an API for writing tabular data and charts to Excel. It is not a replacement for other Excel writing packages such as xlsxwriter, xlwt or pywin32. Instead it uses those packages as a back end to write the Excel files (or to write to Excel directly in the case of pywin32) and provides a higer level abstraction that allows the programmer to deal with tables of data rather than worry about writing individual cells.

The main feature that makes xltable more useful than just writing the Excel files directly is that it can handle tables with formulas that relate to cells in the workbook without having to know in advance where those tables will be placed on a worksheet. Only when all the tables have been added to the workbook and the workbook is being written are formulas resolved to their final cell addresses.

Tables of data are constructed using pandas.DataFrame objects. These can contain formulas relating to columns or cells in the same table or other tables in the same workbook.

As well as writing tables to Excel, xltable can also write charts using tables as source data.

Integrating xltable into Excel can be done using PyXLL, https://www.pyxll.com. PyXLL embeds a Python interpreter within Excel and makes it possible to use Excel as a front end user interface to Python code. For example, you could configure a custom ribbon control for users to run Python reports and have the results written back to Excel.

Example:

from xltable import *
import pandas as pa

# create a dataframe with three columns where the last is the sum of the first two
dataframe = pa.DataFrame({
        "col_1": [1, 2, 3],
        "col_2": [4, 5, 6],
        "col_3": Cell("col_1") + Cell("col_2"),
}, columns=["col_1", "col_2", "col_3"])

# create the named xlwriter Table instance
table = Table("table", dataframe)

# create the Workbook and Worksheet objects and add table to the sheet
sheet = Worksheet("Sheet1")
sheet.add_table(table)

workbook = Workbook("example.xlsx")
workbook.add_sheet(sheet)

# write the workbook to the file (requires xlsxwriter)
workbook.to_xlsx()

Release files for xltable 0.2.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xltable 0.2.13
File Size Uploaded
xltable-0.2.13.tar.gz 19.9 kB Details

Release files / xltable-0.2.13.tar.gz

Download URL xltable-0.2.13.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3976bca3c63a1f4bbd0e4aaf5ec21f34a886da22cceb762a51621a7a56056724
BLAKE2b-256 checksum
How to use checksums
b455dfb1d482566f05e2254019c3e313b177ebe7a22d0121f38c400d7b1339f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.13 This release

1 release file

0.2.12

1 release file

0.2.11

1 release file

0.2.10

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

2 release files

0.2.6

1 release file

0.2.5

1 release file

0.2.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page