gspread icon indicating copy to clipboard operation
gspread copied to clipboard

Fill in same value for all merged cells when calling get_all_values

Open aiguofer opened this issue 5 years ago • 4 comments

Fixes #700

Thought about making this an option, but it seems like it should just be the default behavior.

aiguofer avatar Mar 31 '20 05:03 aiguofer

@aiguofer I never used gspread with a sheet containing merged cells so I'm not sure how frequent is the scenario where you fetch all values from such a sheet.

I have two concerns with marking this a default behavior:

  1. Wouldn't this change brake any existing code that uses gspread?
  2. Even if there are no merged cells, we do a second API call, doubling the number of API calls for get_all_values()

burnash avatar Apr 01 '20 15:04 burnash

Weird, I had added a comment which related to your 2nd point but hadn't actually submitted it. Here's my take on both:

Wouldn't this change brake any existing code that uses gspread?

I don't think it would... if there's no merged cells then this code won't do anything. If there are, I would imagine the expectation is that the same value is displayed for all cells in the merged range. It'd be interesting to know how people are currently handling this and whether they're manually filling in the values. That being said, I would not be opposed to making a param to handle it only when desired.

Even if there are no merged cells, we do a second API call, doubling the number of API calls for get_all_values()

This is certainly more concerning. I have an idea on how to handle this and will make a PR. I think keeping a copy of the entire Spreadsheet metadata on the Spreadsheet, and using a reference to the specific Worksheet metadata within a Worksheet might help. We could then update that when any API calls that change it happen. I think the hardest thing there will be to ensure that gets updated on any new metadata-updating function calls that get implemented.

Let's not merge this in yet, and I'll play around with how to handle the metadata.

aiguofer avatar Apr 03 '20 02:04 aiguofer

Sorry, been pretty busy recently... I have some local changes I haven't pushed yet. I'll try to get to it this week

aiguofer avatar May 04 '20 20:05 aiguofer

No problem :)

burnash avatar May 06 '20 08:05 burnash