exceljs / exceljs/exceljs

[BUG] line-break in table header generates error in Excel for Mac

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

Description

## 🐛 Bug Report

Using line break characters in the header of a table generates an error when trying to open the generated file on Mac.

Lib version: 4.2.1

## Steps To Reproduce

```javascript
const workbook = new ExcelJS.Workbook();

const worksheet = workbook.addWorksheet(title, {
properties: {
defaultColWidth: 30,
},
pageSetup: {
paperSize: 9,
orientation: 'landscape',
},
});

worksheet.addTable({
name: 'table',
ref: 'A1',
headerRow: true,
style: {
theme: 'TableStyleLight2',
showRowStripes: true,
},
columns: [
{ name: 'Test\r\nmultiple\r\nlines' },
],
rows: [
['Test'],
],
});

worksheet.getCell('A1').alignment = { wrapText: true };

await workbook.xlsx.writeFile('test.xlsx');
```

## The expected behaviour:

After the file gets stored, we can open it and see its content.

## The actual behaviour:

An error pops up:

Screenshot 2022-09-16 at 15 29 52

Screenshot 2022-09-16 at 15 30 12

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.