fix(knowledge): retain embedded images when parsing Excel files - #2401
Open
yaojin3616 wants to merge 1 commit into
Open
fix(knowledge): retain embedded images when parsing Excel files#2401yaojin3616 wants to merge 1 commit into
yaojin3616 wants to merge 1 commit into
Conversation
Multi-sheet Excel files with embedded images lost every image during knowledge parsing: md_from_excel exported only cell values, so image-bearing sheets lost their visual content and image-only sheets were dropped entirely. - extract per-sheet embedded images (openpyxl) into the loader's flat image staging dir and reference them from the generated markdown at their anchor row (images beyond the data range ride on the last chunk; image-only sheets now emit their images instead of being skipped) - ExcelLoader / XinChuangFormatterLoader honor the file rule's retain_images flag and rewrite local image refs to the final MinIO URLs; ImageUploadTransformer picks the staged bytes up unchanged - legacy handler() path (patch_130) keeps its previous behavior - add regression tests under test/knowledge/ Refs: Gitee issue IKC7BU (带图片的多sheet文件解析,解析格式不对)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gitee issue IKC7BU: 带图片的多 sheet Excel 文件解析后图片内容全部丢失(解析格式与原文件不一致)。
Root cause:
md_from_excel(the fixed Excel → markdown parse path for xlsx/xls in the knowledge pipeline) only exported cell values. Every embedded image was silently dropped; a sheet whose content was only an image was skipped as "empty".Changes:
md_from_excel.py: extract each sheet's embedded images (openpyxl) into the loader's flat image staging dir; reference them from the generated markdown at the image's anchor row. Images anchored beyond the data range ride on the last chunk; image-only sheets now emit their images instead of being dropped.ExcelLoader/XinChuangFormatterLoader(etformat): honor the file rule'sretain_imagesflag, rewrite local image refs to final MinIO URLs via the existingrewrite_local_image_refscontract —ImageUploadTransformeruploads the staged bytes unchanged (both Knowledge and Preview pipelines already wire it for excel).handler()path (patch_130) keeps its previous behavior.Test plan
test/knowledge/test_md_from_excel_images.py(3 passed): anchor-row extraction, multi-sheet markdown keeps image refs, image-only sheet retained, legacy no-image_dirbehavior unchangedRefs: Gitee issue IKC7BU (https://gitee.com/Data-Elem_1/dashboard/issues?id=IKC7BU)