import openpyxl as xl wb = xl.load_workbook() ws = wb.active for row in ws.row_dimensions: if row > ws.max_row: ws.row_dimensions[row].outlineLevel = 0