File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,21 @@ def parse_xls(wb, sheets):
143
143
def parse_xlsx (wb , sheets ):
144
144
for name in wb .sheetnames :
145
145
ws = wb [name ]
146
- verify_size (ws .max_row , ws .max_column , '.xlsx' )
147
- header_row = next (ws .iter_rows (max_row = 1 , values_only = True ))
146
+ max_row = ws .max_row or 0
147
+ max_col = ws .max_column or 0
148
+ verify_size (max_row , max_col , '.xlsx' )
149
+
150
+ if max_row == 0 or max_col == 0 :
151
+ sheets [name ] = ([], [])
152
+ continue
153
+
154
+ header_row = next (ws .iter_rows (max_row = 1 , values_only = True ), [])
148
155
fields = fix_headers (header_row )
149
156
rows = [
150
157
dict (zip (fields , row ))
151
158
for row in ws .iter_rows (min_row = 2 ,
152
- max_row = ws . max_row ,
153
- max_col = ws . max_column ,
159
+ max_row = max_row ,
160
+ max_col = max_col ,
154
161
values_only = True )
155
162
]
156
163
sheets [name ] = (header_population (fields ), rows )
You can’t perform that action at this time.
0 commit comments