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] One of the great features of Excel is the ability to apply conditional formatting to cell content based on certain conditions. This really helps identify specific data conditions when you have a large amount of data in a worksheet because it's much easier to process visual information. Openpyxl lets you add conditional formatting to your Excel data with some simple Python code. So for this example, we're going to use the FinancialSample Excel file and the data that's in the SalesData worksheet. Let's go ahead and open up our sample code. All right, so you can see here in my sample code, I've already got some code that loads the workbook and gets the SalesData worksheet. So first what we need to do is define some styles to represent the formats that will be applied by the conditions that we specify later. And we do this the same way that we do define styles as we saw earlier in the chapter, when we did the example on creating cell styles. So I'm going to define some…
Contents
-
-
-
-
Overview of openpyxl1m 39s
-
(Locked)
Loading and exploring a workbook9m 9s
-
(Locked)
Creating a workbook6m 50s
-
(Locked)
Working with content8m 10s
-
(Locked)
Styling cells10m 18s
-
(Locked)
Applying conditional formatting7m 7s
-
(Locked)
Adding filters2m 56s
-
(Locked)
Challenge: Split a workbook1m 51s
-
(Locked)
Solution: Split a workbook6m 10s
-
-
-
-