[BUG] Error parsing dynamicFilter in Excel table: "Unexpected xml node in parseOpen"
- Dominant language
- JavaScript
- Stars
- 15.5k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
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
1. Open Excel
2. Create a new workbook
3. 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
4. Convert to a table: `Insert` -> `Table`
5. Select the `Age` filter and choose: `Number filters` -> `Above Average`
Then try to load that file into exceljs with:
```javascript
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):
```javascript
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.