O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing data into worksheets

Reading files is a breeze with the openpyxl module. Now, let's shift our focus to writing Excel files. We'll perform multiple operations with Excel files in this section.

Getting ready

For this recipe, we will use another fantastic Python module, which is xlsxwriter. As the name suggests, this module help us perform multiple operations on Excel sheets. Interestingly, xlsxwriter doesn't support read operations on an Excel sheet (at the time of writing this book). We install the xlsxwrite module using pip, as follows:

pip install xlsxwriter

How to do it...

  1. We start with a very basic operation of creating an XLSX file and adding a new sheet to it. The following code performs this operation:
     import xlsxwriter workbook = xlsxwriter.Workbook('add_sheet.xlsx') ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required