Pārlūkot izejas kodu

pixel to points

tum 11 mēneši atpakaļ
vecāks
revīzija
45c104da19
1 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 7 3
      app/report/gen_report.py

+ 7 - 3
app/report/gen_report.py

@@ -6,7 +6,7 @@ import re
6 6
 
7 7
 from openpyxl.drawing.spreadsheet_drawing import AbsoluteAnchor
8 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 10
 from openpyxl.utils import get_column_letter, column_index_from_string
11 11
 from django.db import models
12 12
 import os
@@ -212,7 +212,9 @@ def gen_xlsx(template_file, selected_sheets, prefix_filename, data):
212 212
 
213 213
                         elif value is True:
214 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 218
                             print(f"{cell.coordinate}")
217 219
                             # sheet.add_image(img, cell.coordinate)
218 220
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
@@ -220,7 +222,9 @@ def gen_xlsx(template_file, selected_sheets, prefix_filename, data):
220 222
                             cell.value = None  # Remove the placeholder text
221 223
                         elif value is False:
222 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 228
                             # sheet.add_image(img, cell.coordinate)
225 229
                             # set_image_with_offset(sheet, img, cell.coordinate, offset_x=100)
226 230
                             center_image_in_cell(sheet, img, cell.coordinate, )