Skip to content

Commit f3562ce

Browse files
committed
Update sheets snippets region tags
1 parent 70047b9 commit f3562ce

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

sheets/snippets/spreadsheet_snippets.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, service):
2020

2121
def create(self, title):
2222
service = self.service
23-
# [START create]
23+
# [START sheets_create]
2424
spreadsheet = {
2525
'properties': {
2626
'title': title
@@ -29,12 +29,12 @@ def create(self, title):
2929
spreadsheet = service.spreadsheets().create(body=spreadsheet,
3030
fields='spreadsheetId').execute()
3131
print('Spreadsheet ID: {0}'.format(spreadsheet.get('spreadsheetId')))
32-
# [END create]
32+
# [END sheets_create]
3333
return spreadsheet.get('spreadsheetId')
3434

3535
def batch_update(self, spreadsheet_id, title, find, replacement):
3636
service = self.service
37-
# [START batch_update]
37+
# [START sheets_batch_update]
3838
requests = []
3939
# Change the spreadsheet's title.
4040
requests.append({
@@ -63,22 +63,22 @@ def batch_update(self, spreadsheet_id, title, find, replacement):
6363
find_replace_response = response.get('replies')[1].get('findReplace')
6464
print('{0} replacements made.'.format(
6565
find_replace_response.get('occurrencesChanged')))
66-
# [END batch_update]
66+
# [END sheets_batch_update]
6767
return response
6868

6969
def get_values(self, spreadsheet_id, range_name):
7070
service = self.service
71-
# [START get_values]
71+
# [START sheets_get_values]
7272
result = service.spreadsheets().values().get(
7373
spreadsheetId=spreadsheet_id, range=range_name).execute()
7474
numRows = result.get('values') if result.get('values')is not None else 0
7575
print('{0} rows retrieved.'.format(numRows));
76-
# [END get_values]
76+
# [END sheets_get_values]
7777
return result
7878

7979
def batch_get_values(self, spreadsheet_id, _range_names):
8080
service = self.service
81-
# [START batch_get_values]
81+
# [START sheets_batch_get_values]
8282
range_names = [
8383
# Range names ...
8484
]
@@ -88,13 +88,13 @@ def batch_get_values(self, spreadsheet_id, _range_names):
8888
result = service.spreadsheets().values().batchGet(
8989
spreadsheetId=spreadsheet_id, ranges=range_names).execute()
9090
print('{0} ranges retrieved.'.format(result.get('valueRanges')));
91-
# [END batch_get_values]
91+
# [END sheets_batch_get_values]
9292
return result
9393

9494
def update_values(self, spreadsheet_id, range_name, value_input_option,
9595
_values):
9696
service = self.service
97-
# [START update_values]
97+
# [START sheets_update_values]
9898
values = [
9999
[
100100
# Cell values ...
@@ -111,13 +111,13 @@ def update_values(self, spreadsheet_id, range_name, value_input_option,
111111
spreadsheetId=spreadsheet_id, range=range_name,
112112
valueInputOption=value_input_option, body=body).execute()
113113
print('{0} cells updated.'.format(result.get('updatedCells')));
114-
# [END update_values]
114+
# [END sheets_update_values]
115115
return result
116116

117117
def batch_update_values(self, spreadsheet_id, range_name,
118118
value_input_option, _values):
119119
service = self.service
120-
# [START batch_update_values]
120+
# [START sheets_batch_update_values]
121121
values = [
122122
[
123123
# Cell values ...
@@ -141,13 +141,13 @@ def batch_update_values(self, spreadsheet_id, range_name,
141141
result = service.spreadsheets().values().batchUpdate(
142142
spreadsheetId=spreadsheet_id, body=body).execute()
143143
print('{0} cells updated.'.format(result.get('updatedCells')));
144-
# [END batch_update_values]
144+
# [END sheets_batch_update_values]
145145
return result
146146

147147
def append_values(self, spreadsheet_id, range_name, value_input_option,
148148
_values):
149149
service = self.service
150-
# [START append_values]
150+
# [START sheets_append_values]
151151
values = [
152152
[
153153
# Cell values ...
@@ -166,7 +166,7 @@ def append_values(self, spreadsheet_id, range_name, value_input_option,
166166
print('{0} cells appended.'.format(result \
167167
.get('updates') \
168168
.get('updatedCells')));
169-
# [END append_values]
169+
# [END sheets_append_values]
170170
return result
171171

172172
def pivot_tables(self, spreadsheet_id):
@@ -186,7 +186,7 @@ def pivot_tables(self, spreadsheet_id):
186186
target_sheet_id = batch_update_response.get('replies')[1] \
187187
.get('addSheet').get('properties').get('sheetId')
188188
requests = []
189-
# [START pivot_tables]
189+
# [START sheets_pivot_tables]
190190
requests.append({
191191
'updateCells': {
192192
'rows': {
@@ -241,13 +241,13 @@ def pivot_tables(self, spreadsheet_id):
241241
}
242242
response = service.spreadsheets() \
243243
.batchUpdate(spreadsheetId=spreadsheet_id, body=body).execute()
244-
# [END pivot_tables]
244+
# [END sheets_pivot_tables]
245245
return response
246246

247247
def conditional_formatting(self, spreadsheet_id):
248248
service = self.service
249249

250-
# [START conditional_formatting]
250+
# [START sheets_conditional_formatting]
251251
my_range = {
252252
'sheetId': 0,
253253
'startRowIndex': 1,
@@ -294,5 +294,5 @@ def conditional_formatting(self, spreadsheet_id):
294294
response = service.spreadsheets() \
295295
.batchUpdate(spreadsheetId=spreadsheet_id, body=body).execute()
296296
print('{0} cells updated.'.format(len(response.get('replies'))));
297-
# [END conditional_formatting]
297+
# [END sheets_conditional_formatting]
298298
return response

0 commit comments

Comments
 (0)