You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding the same image multiple times non-consecutively, ExcelJS adds the wrong image reference.
Example:
constimg1=wb.addImage({filename: 'image1.png',extension: 'PNG'});constimg2=wb.addImage({filename: 'image2.jpg',extension: 'JPEG'});ws.addImage(img2,'A1:A1');// Image 2 ✅ws.addImage(img1,'A3:A3');// Image 1 ✅ws.addImage(img1,'A5:A5');// Should be Image 1, but becomes Image 2! ❌
Root Cause
In lib/xlsx/xform/sheet/worksheet-xform.js, the code only tracks preImageId but not the corresponding relationship ID (rIdImage). When the same image is reused after another image, the relationship ID lookup fails.
Source
Adopt PR exceljs#2876 from exceljs#2876
Also implemented in: https://github.com/Catscratch/exceljs (commit a55ca28)
Problem
When adding the same image multiple times non-consecutively, ExcelJS adds the wrong image reference.
Example:
Root Cause
In
lib/xlsx/xform/sheet/worksheet-xform.js, the code only trackspreImageIdbut not the corresponding relationship ID (rIdImage). When the same image is reused after another image, the relationship ID lookup fails.Solution
PR exceljs#2876 fixes this by:
preRIdImageto track the relationship ID alongsidepreImageIdthis.preRIdImagewhen the same image ID is detectedpreImageIdandpreRIdImagefor next iterationChanges:
Benefits
Attribution
Original PR author: wwwxy80s (@wwwxy80s)
Related
Plan