From e1a12c8684c1ee2b118de6b007db8d0dc2e77854 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 8 Dec 2025 19:13:51 +0800 Subject: [PATCH] refactor: optimize image Excel ID extraction logic in common_handle.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1064254 --user=刘瑞斌 【github#4430】Excel里带图片的数据超过5行上传后不显示图片 https://www.tapd.cn/62980211/s/1807666 --- apps/common/handle/impl/common_handle.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/common/handle/impl/common_handle.py b/apps/common/handle/impl/common_handle.py index 1b1968d97..16c647a96 100644 --- a/apps/common/handle/impl/common_handle.py +++ b/apps/common/handle/impl/common_handle.py @@ -105,9 +105,17 @@ def xlsx_embed_cells_images(buffer) -> {}: cell_images_xml[cnv] = cell_images_rel.get(embed) result = {} for key, img in cell_images_xml.items(): - image_excel_id_list = [_xl for _xl in - reduce(lambda x, y: [*x, *y], [sheet for sheet_id, sheet in sheet_list.items()], []) if - key in _xl] + all_cells = [ + cell + for _sheet_id, sheet in sheet_list.items() + if sheet is not None + for cell in sheet or [] + ] + + image_excel_id_list = [ + cell for cell in all_cells + if isinstance(cell, str) and key in cell + ] # print(key, img) if img is None: continue