From a8511368cea9b8e51964aa5b805f609e5cbf1d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BA=D0=BE=D1=81=20=D0=90=D1=80=D1=82=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Wed, 21 Jan 2026 18:02:00 +0700 Subject: [PATCH] Fix cells width --- redmine_reporter/formatter_odt.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/redmine_reporter/formatter_odt.py b/redmine_reporter/formatter_odt.py index 17294f7..8c639e7 100644 --- a/redmine_reporter/formatter_odt.py +++ b/redmine_reporter/formatter_odt.py @@ -4,6 +4,7 @@ from redminelib.resources import Issue from odf.opendocument import load from odf.text import P from odf.table import Table, TableColumn, TableRow, TableCell +from odf.style import Style, TableColumnProperties from .formatter import get_version, hours_to_human, STATUS_TRANSLATION from .utils import get_month_name_from_range @@ -42,10 +43,22 @@ def format_odt( projects[project][version] = [] projects[project][version].append((issue, hours, status_ru)) - # Создаём таблицу + # Создаем стиль для каждой колонки с нужной шириной + # Ширины из скриншота: 1.56", 1.63", 3.93", 1.56", 1.43" + column_widths = ["1.56in", "1.63in", "3.93in", "1.56in", "1.43in"] + + # Создаем таблицу table = Table(name="Report") - for _ in range(5): - table.addElement(TableColumn()) + + # Добавляем стили для каждой колонки + for i, width in enumerate(column_widths): + col_style_name = f"col{i+1}" + col_style = Style(name=col_style_name, family="table-column") + col_props = TableColumnProperties(columnwidth=width, breakbefore="auto") + col_style.addElement(col_props) + doc.automaticstyles.addElement(col_style) + # Добавляем колонку с этим стилем + table.addElement(TableColumn(stylename=col_style)) # Заголовки header_row = TableRow() @@ -106,8 +119,7 @@ def format_odt( row.addElement(time_cell) table.addElement(row) - - first_version_in_project = False + first_version_in_project = False doc.text.addElement(table) return doc