From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id F116810E04B for ; Fri, 8 Sep 2023 10:32:36 +0000 (UTC) From: Mauro Carvalho Chehab To: igt-dev@lists.freedesktop.org Date: Fri, 8 Sep 2023 12:31:53 +0200 Message-ID: <20230908103218.1089792-12-mauro.chehab@linux.intel.com> In-Reply-To: <20230908103218.1089792-1-mauro.chehab@linux.intel.com> References: <20230908103218.1089792-1-mauro.chehab@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t v5 11/11] scripts/doc_to_xls.py: improve XLS output format List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomasz.mistat@intel.com, jari.tahvanainen@intel.com Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Mauro Carvalho Chehab - Use a bold font for column names; - enable auto-filter; - make it backward compatible with versions of openpyxl shipped on LTS distros. Signed-off-by: Mauro Carvalho Chehab --- scripts/doc_to_xls.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/doc_to_xls.py b/scripts/doc_to_xls.py index 3af3488928cf..c2eaef8fd4b4 100755 --- a/scripts/doc_to_xls.py +++ b/scripts/doc_to_xls.py @@ -25,6 +25,8 @@ Examples: import argparse from openpyxl import Workbook +from openpyxl.utils import get_column_letter +from openpyxl.styles import Font from test_list import TestList @@ -70,17 +72,21 @@ for row in range(len(tests)): for row in range(len(sheet)): for col in range(len(sheet[row])): - ws.cell(row = row + 1, column = col + 1, value = sheet[row][col]) + c = ws.cell(row = row + 1, column = col + 1, value = sheet[row][col]) + if row == 0: + c.font = Font(bold=True) + if len(sheet[row][col]) > max_length[col]: max_length[col] = len(sheet[row][col]) - col = 0 - for c in ws.columns: - column = c[0].column_letter + # Estimate column length + for col in range(len(sheet[0])): + column = get_column_letter(col + 1) adjusted_width = (max_length[col] + 2) * 1.2 ws.column_dimensions[column].width = adjusted_width - col += 1 + # Turn on auto-filter + ws.auto_filter.ref = ws.dimensions wb.save(parse_args.xls) -- 2.41.0