ExcelJS: after AutoFilter, images from hidden rows still show up
22:23 02 Jun 2026

I'm using ExcelJS 4.4.0 + Node.js to export a sheet with images in cells. First open looks fine — each row has its image in column D. But once I turn on AutoFilter and hide some rows, things break: images from the hidden rows don't go away. They stick around or land on the wrong row.

What I want is basically "picture stays with its cell" when filtering. I tried editAs: 'oneCell' but it didn't help.

Here's a minimal repro:

const ExcelJS = require('exceljs');

async function main() {
  const workbook = new ExcelJS.Workbook();
  const sheet = workbook.addWorksheet('test');

  sheet.columns = [
    { header: 'ID', key: 'id', width: 8 },
    { header: 'Name', key: 'name', width: 12 },
    { header: 'Category', key: 'category', width: 12 },
    { header: 'Image', key: 'image', width: 18 },
  ];

  sheet.autoFilter = 'A1:D1';

  const png = Buffer.from(
    'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
    'base64'
  );
  const imageId = workbook.addImage({ buffer: png, extension: 'png' });

  const rows = [
    [1, 'Alpha', 'A'],
    [2, 'Beta', 'B'],
    [3, 'Gamma', 'A'],
    [4, 'Delta', 'B'],
    [5, 'Epsilon', 'A'],
  ];

  for (const [id, name, category] of rows) {
    const row = sheet.addRow([id, name, category, '']);
    sheet.getRow(row.number).height = 40;

    sheet.addImage(imageId, {
      tl: { col: 3, row: row.number - 1 },
      ext: { width: 100, height: 50 },
      editAs: 'oneCell',
    });
  }

  await workbook.xlsx.writeFile('output.xlsx');
  console.log('Done: output.xlsx');
}

main();

How to repro:

  1. npm init -y && npm install exceljs@4.4.0

  2. save as generate.js, run node generate.js

  3. open output.xlsx in WPS 12.1.25897 (macOS)

  4. filter Category (col C), uncheck A

  5. rows 1/3/5 hide, but the image from row 5 (Category A) is still there — sitting below the last visible row

So only rows 2 and 4 should have images. In practice, at least one hidden-row image keeps showing. Screenshots below — I used different colored images per row so it's easier to see which one is wrong.

Before filter:

Before filter

After filter (hide A):

After filter

My setup:

  • ExcelJS 4.4.0

  • Node 20.x

  • macOS 15

  • WPS Office 12.1.25897

Also saw this thread on GitHub — looks related but I couldn't find a fix that works for me.

So my questions are:

  1. Does ExcelJS actually support real "picture in cell" embedding?

  2. If not, is there a addImage setup that behaves OK with AutoFilter? (oneCell vs twoCell, tl/br vs ext, etc.)

Any pointers would be really appreciated — been stuck on this for a while. Thanks!

javascript node.js excel exceljs