Python

OpenPyXL: Create Multi-Sheets Excel Files With This Handy Python Library

This Python library helps you to export dataframes to different sheets within one Excel file

Ismael Araujo
4 min readJan 14, 2023

--

Photo by Rubaitul Azad on Unsplash

Even though Python is mighty, Excel will play a large chunk of work for most data analysts and scientists. Yes, Python can do most of what Excel can do, but most non-technical teams prefer to get their reports in Excel because it’s easier to interact and make changes when working in a multi-department company. However, sometimes Python and Excel files don’t talk to each other in the most effective ways.

Imagine the following scenario: you are working on a project with Python, and you need to export multiple related datasets. All the datasets need to be in the same Excel file but in different tabs; what would you do? I can say what I used to do. I would export each data into different CSV files, one for each dataframe. Then, I would open each file, copy the data, and paste it into an Excel file. I would repeat this process for each file. Finally, I would save the file, and the job would be done.

This doesn’t sound like the most practical way of doing things, and that’s because it’s not.

--

--