|
@@ -27,14 +27,18 @@ class Report():
|
|
|
for column in table.columns:
|
|
|
if table_cell_width is not None:
|
|
|
column.width = Cm(table_cell_width)
|
|
|
- # elif len(text) >= 10:
|
|
|
- # cell.width = Cm(2)
|
|
|
- # elif len(text) >= 15:
|
|
|
- # cell.width = Cm(2.5)
|
|
|
- # elif len(text) >= 25:
|
|
|
- # cell.width = Cm(3)
|
|
|
- # else:
|
|
|
- # cell.width = Cm(1.5)
|
|
|
+ continue
|
|
|
+ max_text_len = 0
|
|
|
+ for cell in column.cells:
|
|
|
+ max_text_len = len(cell.text) if len(cell.text) > max_text_len else max_text_len
|
|
|
+ if max_text_len >= 10:
|
|
|
+ column.width = Cm(2)
|
|
|
+ elif max_text_len >= 15:
|
|
|
+ column.width = Cm(2.5)
|
|
|
+ elif max_text_len >= 25:
|
|
|
+ column.width = Cm(3)
|
|
|
+ else:
|
|
|
+ column.width = Cm(1.5)
|
|
|
|
|
|
@staticmethod
|
|
|
def _set_cell_format(cell, font_size=None):
|