Fix cells width
This commit is contained in:
@@ -4,6 +4,7 @@ from redminelib.resources import Issue
|
|||||||
from odf.opendocument import load
|
from odf.opendocument import load
|
||||||
from odf.text import P
|
from odf.text import P
|
||||||
from odf.table import Table, TableColumn, TableRow, TableCell
|
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 .formatter import get_version, hours_to_human, STATUS_TRANSLATION
|
||||||
from .utils import get_month_name_from_range
|
from .utils import get_month_name_from_range
|
||||||
@@ -42,10 +43,22 @@ def format_odt(
|
|||||||
projects[project][version] = []
|
projects[project][version] = []
|
||||||
projects[project][version].append((issue, hours, status_ru))
|
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")
|
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()
|
header_row = TableRow()
|
||||||
@@ -106,8 +119,7 @@ def format_odt(
|
|||||||
row.addElement(time_cell)
|
row.addElement(time_cell)
|
||||||
|
|
||||||
table.addElement(row)
|
table.addElement(row)
|
||||||
|
first_version_in_project = False
|
||||||
first_version_in_project = False
|
|
||||||
|
|
||||||
doc.text.addElement(table)
|
doc.text.addElement(table)
|
||||||
return doc
|
return doc
|
||||||
|
|||||||
Reference in New Issue
Block a user