From the course: Advanced Hands-On Python: Working with Excel and Spreadsheet Data
Unlock the full course today
Join today to access over 24,600 courses taught by industry experts.
Applying conditional formatting
From the course: Advanced Hands-On Python: Working with Excel and Spreadsheet Data
Applying conditional formatting
- [Instructor] Earlier in the course, we saw how to use the Openpyxl library to apply conditional formatting to a worksheet. In this example, we're going to use XlsxWriter to accomplish the same thing, as well as writing a formula to the worksheet. Now, conditional formatting, as you'll recall, is a way to specify a set of conditions under which to apply a format to a set of cells. Let's go ahead and open up our example code. And you can see, we already have some code to create the workbook and add some data. Essentially, we are reading in the contents of the Inventory.csv file and just writing it out as a Excel workbook named Conditional.xlsx. We also have some code that creates some format definitions and applies them to the data. So this is essentially the same code from the formatting example where we created a workbook from CSV data. So let's start by adding a new column to the data that calculates the profit margin for each product, which is the difference between the consumer…
Contents
-
-
-
-
-
Introduction to XlsxWriter1m 53s
-
(Locked)
Creating a workbook7m 2s
-
(Locked)
Formatting worksheet content5m 39s
-
(Locked)
Creating an Excel table6m 23s
-
(Locked)
Applying conditional formatting8m 16s
-
(Locked)
Writing workbook properties5m 39s
-
(Locked)
Challenge: Split a workbook2m 7s
-
(Locked)
Solution: Split a workbook2m 58s
-
-
-