-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Closed
Copy link
Description
🐛 Bug Report
After specifying numFmt
pattern as a style for conditional formatting rule, MS Excel states a problem during opening generated file. The issue is reproducible for both basic and streaming APIs.
Lib version: 4.2.1
MS Excel version: 16.52
OS: MacOS Big Sur (11.4)
Steps To Reproduce
For issue reproduction, next snippet is suggested (run it and try to open generated file):
const Excel = require('exceljs');
const { WorkbookWriter } = Excel.stream.xlsx;
(async () => {
const workbook = new WorkbookWriter({ filename: 'test.xlsx', useStyles: true });
const worksheet = workbook.addWorksheet('example');
worksheet.addConditionalFormatting({
ref: 'A1:A2',
rules: [{
type: 'cellIs',
operator: 'between',
formulae: [0, 10],
style: { numFmt: '0.00' },
priority: 1,
}],
});
[5.5, 15.5].forEach((value, index) => {
const row = worksheet.getRow(index + 1);
const cell = row.getCell(1);
cell.value = value;
row.commit();
});
worksheet.commit();
await workbook.commit();
})();
Expected Behavior
The file should be generated validly and it should contain specified conditional formatting rules.
Investigation Notes
The issue is described by an invalid numFmt
tag inside styles.xml
:
<dxfs count="1">
<dxf>
<numFmt/>
</dxf>
</dxfs>
While valid markup should look like:
<dxfs count="1">
<dxf>
<numFmt numFmtId="number" formatCode="0.00"/>
</dxf>
</dxfs>
ivanbiletskyi, Schdoop, assada, dhammma, YuliiaVeklycheva and 2 more
Metadata
Metadata
Assignees
Labels
No labels