Skip to main content

Read and write xlsx/xlst using pandas/openpyxl while preserving Excel formatting

Project description


Read and write Excel xlsx using pandas/openpyxl without destroying formatting.

Sometimes you have a nicely formatted worksheet, but you'd like to work with it using pandas, or perhaps you want to write data to an Excel template.

Pandas can read and write Excel files using xlrd, but treats them like csvs. xlPandas uses openpyxl to access data while preserving template formatting, macros, and other worksheet attributes.


pip install xlpandas


import xlpandas as xpd

# Read excel file
df = xpd.read_file('template.xlsx', skiprows=2)

# Modify dataframe
df['new_column'] = True

# Access openpyxl worksheet
sheet = df.to_sheet()
sheet.cell(1,1).value = 'title'

# From openpyxl worksheet
df = xpd.xlDataFrame(sheet)

# Write file

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 xlpandas, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size xlpandas-0.1.4-py3-none-any.whl (4.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size xlpandas-0.1.4.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page