Przeglądaj źródła

pixel to points

tum 11 miesięcy temu
rodzic
commit
45c104da19
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7 3
      app/report/gen_report.py

+ 7 - 3
app/report/gen_report.py

6
 
6
 
7
 from openpyxl.drawing.spreadsheet_drawing import AbsoluteAnchor
7
 from openpyxl.drawing.spreadsheet_drawing import AbsoluteAnchor
8
 from openpyxl.drawing.xdr import XDRPoint2D, XDRPositiveSize2D
8
 from openpyxl.drawing.xdr import XDRPoint2D, XDRPositiveSize2D
9
-from openpyxl.utils.units import pixels_to_EMU
9
+from openpyxl.utils.units import pixels_to_EMU, pixels_to_points
10
 from openpyxl.utils import get_column_letter, column_index_from_string
10
 from openpyxl.utils import get_column_letter, column_index_from_string
11
 from django.db import models
11
 from django.db import models
12
 import os
12
 import os
212
 
212
 
213
                         elif value is True:
213
                         elif value is True:
214
                             img = Image(checked_image_path)
214
                             img = Image(checked_image_path)
215
-                            img.width = img.height = 10
215
+                            img.width = img.height = pixels_to_points(15)
216
+                            # img.width = 15
217
+                            # img.hegiht = 10
216
                             print(f"{cell.coordinate}")
218
                             print(f"{cell.coordinate}")
217
                             # sheet.add_image(img, cell.coordinate)
219
                             # sheet.add_image(img, cell.coordinate)
218
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
220
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
220
                             cell.value = None  # Remove the placeholder text
222
                             cell.value = None  # Remove the placeholder text
221
                         elif value is False:
223
                         elif value is False:
222
                             img = Image(unchecked_image_path)
224
                             img = Image(unchecked_image_path)
223
-                            img.width = img.height = 10
225
+                            # img.width = 15
226
+                            # img.height = 10
227
+                            img.width = img.height = pixels_to_points(15)
224
                             # sheet.add_image(img, cell.coordinate)
228
                             # sheet.add_image(img, cell.coordinate)
225
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
229
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
226
                             center_image_in_cell(sheet, img, cell.coordinate, )
230
                             center_image_in_cell(sheet, img, cell.coordinate, )