Skip to content

Commit

Permalink
Resize to smallest possible size before final size in clear_sheet
Browse files Browse the repository at this point in the history
Workaround for strange resizing bug
  • Loading branch information
aiguofer committed Jan 5, 2022
1 parent 2154684 commit 60e8d93
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gspread_pandas/spread.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,14 @@ def clear_sheet(self, rows=1, cols=1, sheet=None):
row_resize = max(rows, frozen_rows + 1)
col_resize = max(cols, frozen_cols + 1)

# resize to smallest possible size first
# https://issuetracker.google.com/issues/213126648
# TODO: these 2 operations could be done in a single batchUpdate call
self.sheet.resize(frozen_rows + 1, frozen_cols + 1)
self.sheet.resize(row_resize, col_resize)

self.update_cells(
start=(1, 1),
end=(row_resize, col_resize),
vals=["" for i in range(0, row_resize * col_resize)],
)
# clear the value on the first cell since it didn't get deleted above
self.update_cells(start=(1, 1), end=(1, 1), vals=[""])

def delete_sheet(self, sheet):
"""
Expand Down

0 comments on commit 60e8d93

Please sign in to comment.