@@ -182,6 +182,14 @@ def __repr__(self):
182
182
return str (self .value )
183
183
184
184
185
+ def column_to_number (column ):
186
+ column = re .sub ("[^A-Z]" , "" , column )
187
+ cl = len (column ) - 1
188
+ return sum (
189
+ [(ord (c .upper ()) - 64 ) + (26 * (cl - i )) for i , c in enumerate (column )]
190
+ )
191
+
192
+
185
193
def parse_row (row_xml_string , book ):
186
194
if b"x14ac" in row_xml_string :
187
195
row_xml_string = row_xml_string .replace (
@@ -191,11 +199,20 @@ def parse_row(row_xml_string, book):
191
199
cells = []
192
200
cell = Cell ()
193
201
202
+ last_column_number = None
194
203
for action , element in etree .iterparse (partial ):
195
-
196
204
if element .tag in ["v" , "t" ]:
197
205
cell .value = element .text
198
206
elif element .tag in ["c" ]:
207
+ ref = element .attrib .get ("r" )
208
+ if ref :
209
+ column_number = column_to_number (ref )
210
+ if last_column_number is not None :
211
+ padding = column_number - last_column_number - 1
212
+ if padding > 0 :
213
+ cells += [Cell () for _ in range (padding )]
214
+ last_column_number = column_number
215
+
199
216
local_type = element .attrib .get ("t" )
200
217
cell .column_type = local_type
201
218
style_int = element .attrib .get ("s" )
0 commit comments