Skip to content

Commit 0d7ae44

Browse files
committed
In read_excel_as_template, removing non-existing rows and columns from _rows_height and _columns_width
1 parent b0e6e32 commit 0d7ae44

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

styleframe/style_frame.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,19 @@ def read_excel_as_template(cls, path, df, use_df_boundaries=False, **kwargs):
252252

253253
if use_df_boundaries:
254254
sf.data_df = sf.data_df.iloc[:num_of_rows, :num_of_cols]
255-
sf._rows_height = {k: v for i, (k, v) in enumerate(sf._rows_height.items())
256-
if i in range(num_of_rows)}
257-
sf._columns_width = {k: v for i, (k, v) in enumerate(sf._columns_width.items())
258-
if i in range(num_of_cols)}
255+
rows_height = OrderedDict()
256+
rows_height_range = range(num_of_rows)
257+
for i, (k, v) in enumerate(sf._rows_height.items()):
258+
if i in rows_height_range:
259+
rows_height[k] = v
260+
sf._rows_height = rows_height
261+
262+
columns_width = OrderedDict()
263+
columns_width_range = range(num_of_cols)
264+
for i, (k, v) in enumerate(sf._columns_width.items()):
265+
if i in columns_width_range:
266+
columns_width[k] = v
267+
sf._columns_width = columns_width
259268
return sf
260269

261270
# noinspection PyPep8Naming

0 commit comments

Comments
 (0)