Summary
Adopt upstream PR exceljs#2978 (partial) to fix crashes when autofilter column index refers to an undefined column.
In some Excel files, the autofilter configuration references column indices that don't exist in the table model, causing crashes when trying to assign the filterButton property to undefined columns.
Upstream PR
Changes
File modified:
lib/xlsx/xform/table/table-xform.js - Add guard for undefined columns (3 lines)
Total: 3 additions, 0 deletions
Note: The upstream PR includes additional changes to data-validations-xform.js and package.json. We are only adopting the table-xform.js fix as it's the core bug fix. The other changes are either unrelated or inappropriate for our fork.
Bug Description
When parsing Excel files with autofilter configurations that reference non-existent columns, ExcelJS crashes trying to set properties on undefined objects.
Current behavior:
this.map.autoFilter.model.columns.forEach((column, index) => {
this.model.columns[index].filterButton = column.filterButton;
// Crashes if this.model.columns[index] is undefined
});
Fixed behavior:
this.map.autoFilter.model.columns.forEach((column, index) => {
if (!this.model.columns[index]) {
return; // Skip undefined columns
}
this.model.columns[index].filterButton = column.filterButton;
});
Value Proposition
- Low Risk - Simple guard clause addition
- Bug Fix - Prevents crashes on malformed Excel files
- Robustness - Improves error handling for edge cases
Testing Plan
Summary
Adopt upstream PR exceljs#2978 (partial) to fix crashes when autofilter column index refers to an undefined column.
In some Excel files, the autofilter configuration references column indices that don't exist in the table model, causing crashes when trying to assign the
filterButtonproperty to undefined columns.Upstream PR
Changes
File modified:
lib/xlsx/xform/table/table-xform.js- Add guard for undefined columns (3 lines)Total: 3 additions, 0 deletions
Note: The upstream PR includes additional changes to data-validations-xform.js and package.json. We are only adopting the table-xform.js fix as it's the core bug fix. The other changes are either unrelated or inappropriate for our fork.
Bug Description
When parsing Excel files with autofilter configurations that reference non-existent columns, ExcelJS crashes trying to set properties on undefined objects.
Current behavior:
Fixed behavior:
Value Proposition
Testing Plan