jsonkenl / xlsxir

Xlsx parser for the Elixir language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MatchError when Parsing XLSX

barakyo opened this issue · comments

Hi!

Thanks for the great library. We're using this in production and noticed that we're having an error when trying to parse XLSX files whose columns may be missing some style information (for example a column with no values). The error seems to go away when we directly delete that that column.

This is the error we get:

(MatchError) no match of right hand side value: []

(xlsxir) lib/xlsxir/parse_style.ex:69: Xlsxir.ParseStyle.sax_event_handler/2
(erlsom) xlsxir/deps/erlsom/src/erlsom_sax_utf8.erl:1408: :erlsom_sax_utf8.wrapCallback/2
(erlsom) xlsxir/deps/erlsom/src/erlsom_sax_utf8.erl:936: :erlsom_sax_utf8.parseContentLT/2
(erlsom) xlsxir/deps/erlsom/src/erlsom_sax_utf8.erl:196: :erlsom_sax_utf8.parse/2
(xlsxir) lib/xlsxir/sax_parser.ex:61: Xlsxir.SaxParser.parse/3
(xlsxir) lib/xlsxir/xlsx_file.ex:225: Xlsxir.XlsxFile.parse_styles_to_ets/1
(xlsxir) lib/xlsxir/xlsx_file.ex:65: Xlsxir.XlsxFile.initialize/2
(xlsxir) lib/xlsxir.ex:88: Xlsxir.extract/4

I've attached the spreadsheet, missing_styles.xlsx, where this occurs.

As a heads up, I have a fix for this, but I thought it would better to log an issue and open a PR which fixes this.

@barakyo thanks for pointing out this bug and proposing a fix. I'll get it merged ASAP and will publish a new version on hex once I get a chance to look into issue #93.