Jelajahi Sumber

modify: 报告格式调整

yq 5 bulan lalu
induk
melakukan
a532ebf18d
1 mengubah file dengan 12 tambahan dan 8 penghapusan
  1. 12 8
      monitor/report_generate.py

+ 12 - 8
monitor/report_generate.py

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