-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
🐛 Bug Report
Full repo to easily reproduce this bug is available here: https://github.com/examind-ai/exceljs-dynamicfilter-bug
Lib version: 4.4.0
ExcelJS fails to parse Excel files containing dynamicFilter elements in table XML with the error: Unexpected xml node in parseOpen. This occurs when Excel tables use dynamic filters (like "Above Average"), but only affects table-level filters - worksheet-level dynamic filters parse successfully.
Steps To Reproduce
- Open Excel
- Create a new workbook
- Add sample data
ID | Age |
---|---|
1 | 10 |
2 | 11 |
3 | 12 |
4 | 13 |
5 | 14 |
6 | 15 |
7 | 16 |
8 | 17 |
9 | 18 |
10 | 19 |
- Convert to a table:
Insert
->Table
- Select the
Age
filter and choose:Number filters
->Above Average
Then try to load that file into exceljs with:
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile('excel-file.xlsx');
The expected behaviour:
Expect ExcelJS to not throw an exception. Instead, it results in this exception:
exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xform\table\filter-column-xform.js:72
throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
^
Error: Unexpected xml node in parseOpen: {"name":"dynamicFilter","attributes":{"type":"aboveAverage","val":"14.5"},"isSelfClosing":true}
at FilterColumnXform.parseOpen (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xform\table\filter-column-xform.js:72:15)
at AutoFilterXform.parseOpen (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xform\table\auto-filter-xform.js:37:19)
at TableXform.parseOpen (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xform\table\table-xform.js:57:19)
at TableXform.parse (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xform\base-xform.js:63:16)
at async XLSX._processTableEntry (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xlsx.js:165:19)
at async XLSX.load (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xlsx.js:393:15)
at async XLSX.readFile (exceljs-dynamicfilter-bug\node_modules\exceljs\lib\xlsx\xlsx.js:55:24)
Full repo to easily reproduce this bug is available here: https://github.com/examind-ai/exceljs-dynamicfilter-bug
Possible solution (optional, but very helpful):
Metadata
Metadata
Assignees
Labels
No labels