Skip to content

Commit

Permalink
Fix numFmtID when chk_exists returns None
Browse files Browse the repository at this point in the history
cellXfs._attrs['applyNumberFormat'].value returns a literal 'true' or 'false' which throws an error when int() is called. Switch numFmtId = int(cellXfs._attrs['applyNumberFormat'].value) to numFmtId = int(cellXfs._attrs['applyNumberFormat'].value == 'true')
  • Loading branch information
Michael Carvell committed Oct 16, 2020
1 parent b2d2a3c commit 71f78ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xlsx2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def parse(self, filehandle):
if cellXfs._attrs and 'numFmtId' in cellXfs._attrs:
numFmtId = int(cellXfs._attrs['numFmtId'].value)
if self.chk_exists(numFmtId) == None:
numFmtId = int(cellXfs._attrs['applyNumberFormat'].value)
numFmtId = int(cellXfs._attrs['applyNumberFormat'].value == 'true')
self.cellXfs.append(numFmtId)
else:
self.cellXfs.append(None)
Expand Down

1 comment on commit 71f78ce

@carvitup
Copy link

@carvitup carvitup commented on 71f78ce Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cellXfs._attrs['applyNumberFormat'].value returns a literal 'true' or 'false' which throws an error when int() is called. Switch numFmtId = int(cellXfs._attrs['applyNumberFormat'].value) to numFmtId = int(cellXfs._attrs['applyNumberFormat'].value == 'true')

Fix for Issue #207

Please sign in to comment.