exceljs / exceljs/exceljs

corrupted file when have 2 or more same column names

Open
#2,944 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15.5k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

## 🐛 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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.