exceljs icon indicating copy to clipboard operation
exceljs copied to clipboard

corrupted file when have 2 or more same column names

Open ybonchev opened this issue 6 months ago • 0 comments

🐛 Bug Report

as the name states, this is only occurs when 2 or more column names are the same

Lib version: "exceljs": "^4.4.0",

Steps To Reproduce

so i'm using this method here to create a table: const permissionsExcelReportTable = worksheet.addTable({ name: 'Files', ref: A${worksheet.lastRow ? worksheet.lastRow.number + 2 : 1}, headerRow: true, style: { theme: 'TableStyleLight8', showRowStripes: true, }, columns: permissionsTableHeader.map((c) => ({ name: c })), rows: permissionsExcelReportRows, }); so what i discovered is that if this variable permissionsTableHeader looks like this: array.map((l) => 'foo'); then file throws an error, yes you can still recover it and will it work just fine but... all my column names will not be actually foo they will be named as: foo, foo1, foo2, etc which makes me think that this is how this table forms, maybe there should be an option like id or something? because it makes sense that it does this, because names are the same, but from the user perspective it doesnt, cause those are technically still just cells and you can rename them back to "foo" without any problems

The expected behaviour:

not throwing an error? :)

Possible solution (optional, but very helpful):

add an id or whatever?

ybonchev avatar Jul 01 '25 17:07 ybonchev