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
Generating the excel with image is broken in version 4.4.0, I have scenario where we need to add image into each row of the column. I have used the function addImage.
Lib version: 4.4.0
Steps To Reproduce
The below code generate the excel sheet, which would have headers (Column 1, Column 2, Column 3) along with data row with respective header. But the generated excel is broken, the images miss aligned in order and size.
constExcelJs=require('exceljs');constpath=require('path');constitems=[{col1: "abc",col2: newDate(),col3: "dummyImage.jpg"},{col1: "dummy1",col2: newDate(),col3: "dummyImage.jpg"},{col1: "dummy2",col2: newDate(),col3: "dummyImage.jpg"}]constgenerateExcel=async()=>{constworkbook=newExcelJs.Workbook();letws=workbook.addWorksheet('my first worksheet');ws.columns=[{header: 'column 1',key: 'col1'},{header: 'column 2',key: 'col2'},{header: 'column 3',key: 'col3'}];ws.getRow(1).eachCell((cell)=>{cell.fill={type: 'pattern',pattern: 'solid',fgColor: {argb: '0082f0'}};cell.font={bold: true,color: {argb: 'fafafa'}}})// add a filter to the header rowws.autoFilter='A1:C1';// freeze the header rowws.views=[{state: 'frozen',xSplit: 0,ySplit: 1,topLeftCell: 'A2',activeCell: 'A2'}];letrowPos=2;for(letitemofitems){ws.addRow({col1: item.col1,col2: item.col2})if(item.col3){constimageId=workbook.addImage({filename: path.join('images',item.col3),extension: 'jpeg',});letcellName=`C${rowPos}:C${rowPos}`;ws.addImage(imageId,cellName);}letlastRow=ws.lastRow;lastRow.height=115;rowPos++;}constfilename=`todo.xlsx`;awaitworkbook.xlsx.writeFile(filename);returnfilename;}generateExcel();
The expected behaviour:
This is output of the exceljs version 4.3.0 with same above code
The excel which get generated should have sheet with three columns and each row data get align with respective order along with image.
Possible solution (optional, but very helpful):
The text was updated successfully, but these errors were encountered:
Due to changes in anchor.js (#1934) , it seems that a new row may be added when using addImage.
Until this is fixed, it is advisable to explicitly specify the row to use when employing addImage.
For instance, the following code should work.
🐛 Bug Report
Generating the excel with image is broken in version 4.4.0, I have scenario where we need to add image into each row of the column. I have used the function addImage.
Lib version: 4.4.0
Steps To Reproduce
The below code generate the excel sheet, which would have headers (Column 1, Column 2, Column 3) along with data row with respective header. But the generated excel is broken, the images miss aligned in order and size.
The expected behaviour:
This is output of the exceljs version 4.3.0 with same above code
The excel which get generated should have sheet with three columns and each row data get align with respective order along with image.
Possible solution (optional, but very helpful):
The text was updated successfully, but these errors were encountered: