exceljs / exceljs

Excel Workbook Manager
MIT License
13.09k stars 1.67k forks source link

[BUG] addBackgroundImage not working #2728

Open jerryheir opened 2 months ago

jerryheir commented 2 months ago

🐛 Bug Report

addBackgroundImage not working. addImage and eachSheet are working fine. even ws.addImage works fine.

But addBackgroundImage is not working ...

Lib version: X.Y.Z

Steps To Reproduce

    const imageId = workbook.addImage({
      buffer: image as Buffer,
      extension: "png",
    });
    workbook.eachSheet((ws, _sheetId) => {

      ws.addBackgroundImage(imageId);

   })

The expected behaviour:

Image to be added to background successfully

"exceljs": "^4.4.0"

node 18.17.1

ashmitbp99 commented 2 months ago

+1

Unable to see background image when adding with the following code:


    worksheet.columns = rows[0].map(header => {
      return { header, key: `column${header}`, width: columnWidthMap[header] || columnWidthMap.default }
    })

    worksheet.insertRows(2, rows.slice(1))

    const imageId1 = workbook.addImage({
      filename: 'src/modules/survey/mail_logo.png',
      extension: 'png',
    })

    worksheet.addBackgroundImage(imageId1) // does not work
    return workbook```

    using 
    exceljs "^4.4.0"
    node v21.6.1