Skip to content

Commit e1a12c8

Browse files
committed
refactor: optimize image Excel ID extraction logic in common_handle.py
--bug=1064254 --user=刘瑞斌 【github#4430】Excel里带图片的数据超过5行上传后不显示图片 https://www.tapd.cn/62980211/s/1807666
1 parent 31f2306 commit e1a12c8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

apps/common/handle/impl/common_handle.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ def xlsx_embed_cells_images(buffer) -> {}:
105105
cell_images_xml[cnv] = cell_images_rel.get(embed)
106106
result = {}
107107
for key, img in cell_images_xml.items():
108-
image_excel_id_list = [_xl for _xl in
109-
reduce(lambda x, y: [*x, *y], [sheet for sheet_id, sheet in sheet_list.items()], []) if
110-
key in _xl]
108+
all_cells = [
109+
cell
110+
for _sheet_id, sheet in sheet_list.items()
111+
if sheet is not None
112+
for cell in sheet or []
113+
]
114+
115+
image_excel_id_list = [
116+
cell for cell in all_cells
117+
if isinstance(cell, str) and key in cell
118+
]
111119
# print(key, img)
112120
if img is None:
113121
continue

0 commit comments

Comments
 (0)