I'm using Python API https://developers.google.com/sheets/api/quickstart/python
I have a sheet looks like this and want to automate some cell filling logic
| A | B |
--+------+------+
1 | a1 | b1 |
--+------+ |
2 | a2 | |
--+------+------+
3 | a3 | b2 |
--+------+------+
While using readRange
= "A1:B" by
spreadsheet_id = 'my-spreadsheet-id'
ranges = []
include_grid_data = False # TODO: Update placeholder value.
request = service.spreadsheets().get(spreadsheetId=spreadsheet_id, ranges=ranges, includeGridData=include_grid_data)
response = request.execute()
pprint(response)
how can i retrieve the information of merge cells in a sheet using Sheets API?
The list of merged cells are defined in the merges
property of the sheet. From the code you posted, it would be: response['sheets'][0]['merges']
(but with the necessary error code handling). It's worth noting that this will only show the merges in the specified range, not all of them.