jsonkenl/xlsxir

Error in ParseWorksheet.format_cell_value/1

pma opened this issue · 5 comments

pma commented

I'm getting an error in ParseWorksheet.format_cell_value/1 (https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir/parse_worksheet.ex#L99) where list has the value ['str', 'd', s].

The problematic cell seems to be one with a text formula:

<c r="F2" s="12" t="str">
        <f>CONCATENATE(...edited...)</f>
        <v>Mensalidade de Maio de 2016</v>
      </c>

As a quick fix, I added an extra ['str', _, s] -> List.to_string(s) to the case statement. I'm wondering if you might have a better insight on the issue and a more elegant solution.

I can get more relevant info from this file if you can point me in the right direction.

@pma Thanks for letting me know. I'll try and take a look at it tonight when I get home from work. Will keep you posted.

@pma Actually, could you please crack open the file and send me a gist of styles.xml located at xl/styles.xml?

pma commented

@kennellroxco Here. I passed it through xmllint for readability:
https://gist.github.com/pma/1ecd46e68af00d230b46f14094e09a73

@pma For some reason that text formula has a style type of <numFmt numFmtId="164" formatCode="yyyy/mm/dd"/> which is why it's coming through with a 'd' in ['str', 'd', s]. I should be able to modify the original case statement of ['str', nil, s] -> List.to_string(s) to ['str', _, s] -> List.to_string(s) since any time the data type is str the result should be a string. So in effect, your "quick fix" is the right answer. I'll make the adjustment and push out in the next version. Thanks!

@pma I just released the fix in v1.3.3 on Hex. Let me know if you have any other issues. Thanks!