Python(Openpyxl) Tip-1:: Apply Filter on All Excel Sheets

Python(openpyxl) Tip-1:
This Python code creates a new worksheet named “Title Page” at the beginning of an existing workbook using the openpyxl library. It then adds a header to the new worksheet by setting the value of cell J11 to “UMTS Technology Daily Audits” and formatting it using the Font, border, and Alignment styles from the openpyxl.styles module. The width of column J is also set to 40.

Next, the code loops through all sheets in the workbook and adds a hyperlink to each sheet in the “Title Page” worksheet. For each sheet, it gets the sheet name and inserts it as a value in a cell in column J of the “Title Page” worksheet. It then adds a hyperlink to the same cell that links to the beginning of the corresponding sheet. The color, underline, border, and alignment styles are applied to the cell, and the height of the row is set to 20.

Note that the code assumes that the variable “border” has been defined earlier in the code to specify a border style for the cells.

1 Like