def _write_excel_rows(rows: list, workbook: Workbook, worksheet: Worksheet) -> int: excel_longest_word = '' for i, row in enumerate(rows, 1): row_format = None if i == 1: row_format = workbook.add_format({ 'bold': True, 'bg_color': '#cccccc', }) elif i % 2 == 0: row_format = workbook.add_format({ 'bg_color': '#f1f1f1', }) range_cells = 'A%s:I10' % i row_longest_word = find_longest_word(row) if len(row_longest_word) > len(excel_longest_word): excel_longest_word = row_longest_word worksheet.write_row(range_cells, row, row_format) self.update_state(state='PROGRESS', meta={ 'current': i, 'total': self.total_progress, 'status': 'In progress...', }) return len(excel_longest_word)