🐛 Bug Report
Reading certain XLSX files that contain drawings (charts, userShapes, protected shapes) crashes with:
TypeError: Cannot read properties of undefined (reading 'anchors') at /node_modules/@protobi/exceljs/lib/xlsx/xlsx.js at XLSX.reconcile at XLSX.load
A second unguarded access exists in lib/xlsx/xform/sheet/worksheet-xform.js:
drawing.anchors.forEach(anchor => { // CRASH if drawing is undefined
The 4.4.0-protobi.9 round-trip preservation partially mitigates this by routing chart-containing drawings to preservedDrawingsXml instead of parsing. But non-chart drawings that fail to parse (e.g., c:userShapes, certain protected files) still hit this path and crash.
Lib version: 4.4.0-protobi.9
Steps To Reproduce
- Open an XLSX file in Excel that contains charts or complex drawing objects
- Read it with @protobi/exceljs
const ExcelJS = require('@protobi/exceljs');
const wb = new ExcelJS.Workbook();
await wb.xlsx.readFile('file-with-drawings.xlsx');
- Observe the TypeError crash
The expected behaviour:
The file should load without crashing. Users reading these files typically only need cell data, not drawing/chart content.
References
Upstream issue: exceljs/exceljs#2591
Proposed fix from @markusjohnsson
Additional fix from @DarkTraveler
Possible solution (optional, but very helpful):
lib/xlsx/xlsx.js file, in the reconcile method on line exceljs#97— add drawing && to the guard in reconcile:
change
to
if (drawing && drawingRel) {
🐛 Bug Report
Reading certain XLSX files that contain drawings (charts, userShapes, protected shapes) crashes with:
TypeError: Cannot read properties of undefined (reading 'anchors') at /node_modules/@protobi/exceljs/lib/xlsx/xlsx.js at XLSX.reconcile at XLSX.load
A second unguarded access exists in lib/xlsx/xform/sheet/worksheet-xform.js:
The 4.4.0-protobi.9 round-trip preservation partially mitigates this by routing chart-containing drawings to preservedDrawingsXml instead of parsing. But non-chart drawings that fail to parse (e.g., c:userShapes, certain protected files) still hit this path and crash.
Lib version: 4.4.0-protobi.9
Steps To Reproduce
The expected behaviour:
The file should load without crashing. Users reading these files typically only need cell data, not drawing/chart content.
References
Upstream issue: exceljs/exceljs#2591
Proposed fix from @markusjohnsson
Additional fix from @DarkTraveler
Possible solution (optional, but very helpful):
lib/xlsx/xlsx.js file, in the reconcile method on line exceljs#97— add drawing && to the guard in reconcile:
change
to