Skip to content

Commit 862d038

Browse files
committed
👕 minor code refactoring
1 parent 4953785 commit 862d038

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

pyexcel_xlsxr/messy_xlsx.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,7 @@ def parse_row(row_xml_string, book):
203203

204204
def parse_cell(cell, book):
205205
cell.type = parse_cell_type(cell)
206-
if cell.column_type == 's':
207-
cell.value = book.shared_strings[int(cell.value)]
208-
elif cell.column_type == 'b':
209-
cell.value = (
210-
(int(cell.value) == 1 and "TRUE") or
211-
(int(cell.value) == 0 and "FALSE") or
212-
cell.value)
213-
elif cell.column_type == 'n':
214-
parse_cell_value(cell, book)
215-
# else
216-
# no action
206+
parse_cell_value(cell, book)
217207

218208
def parse_cell_type(cell):
219209
cell_type = None
@@ -233,8 +223,21 @@ def parse_cell_type(cell):
233223
cell_type = "float"
234224
return cell_type
235225

236-
237226
def parse_cell_value(cell, book):
227+
if cell.column_type == 's':
228+
cell.value = book.shared_strings[int(cell.value)]
229+
elif cell.column_type == 'b':
230+
cell.value = (
231+
(int(cell.value) == 1 and "TRUE") or
232+
(int(cell.value) == 0 and "FALSE") or
233+
cell.value)
234+
elif cell.column_type == 'n':
235+
parse_numeric_cell_value(cell, book)
236+
# else
237+
# no action
238+
239+
240+
def parse_numeric_cell_value(cell, book):
238241
try:
239242
if cell.type == 'date': # date/time
240243
if book.properties['date1904']:

0 commit comments

Comments
 (0)