Skip to content

[BUG] "unexpected close tag" error from saxes when parsing an excel with multiline text #1958

@lmX2015

Description

@lmX2015

🐛 Bug Report

When trying to read an excel files with "/
/" tags (for instance on multi row text within a button), ExcelJS crash with the following error

Error: 43:10: unexpected close tag.
at SaxesParser.makeError ( --- node_modules/saxes/saxes.js:410:16)
at SaxesParser.fail (--- node_modules/saxes/saxes.js:422:26)
at SaxesParser.closeTag (--- node_modules/saxes/saxes.js:2019:18)
at SaxesParser.sCloseTag (--- node_modules/saxes/saxes.js:1605:18)
at SaxesParser.write (--- node_modules/saxes/saxes.js:481:36)
at module.exports (---  node_modules/exceljs/lib/utils/parse-sax.js:21:17)

In short this is due to XML code that is accepted by Excel but refused by the saxes parser (typically unclosed tags)

Lib version: 3.10.0 or higher (tested up to 4.3.0). Seems to work on 3.9.0, since the issue comes from saxes that was introduced in replacement of sax-js (see comment below).

Steps To Reproduce

Import this file bugged.xlsx

const workbook = new Workbook();
workbook.xlsx.load(file);

The expected behaviour:

File should be loaded without crashing.

Related issue

##1316 previously reported the bug without further details.

Possible solution

See below

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions