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

Formatting Excel cells

Cells are formatted for various reasons. In the business world, they are used to group data based on a theme, or in the case of a software development process, cells are colored to indicate whether a feature is done or a bug is fixed.

Getting ready

For this recipe, we will use the same xlsxwriter module and format the cells. We will learn how to add and apply formats to the cells.

How to do it...

  1. We continue with the expenses example to demonstrate the formatting of cells. But first let's understand how to create formats. Formats are added with the  add_format() method. This method returns a format object. The following code example shows how to create a format:
     format = workbook.add_format() format.set_bold() format.set_font_color('green') ...

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