@Test public void testBatchUpdate() throws IOException { String spreadsheetId = this.createTestSpreadsheet(); this.populateValuesWithStrings(spreadsheetId); BatchUpdateSpreadsheetResponse response = this.snippets.batchUpdate(spreadsheetId, "New Title", "Hello", "Goodbye"); List<Response> replies = response.getReplies(); assertEquals(2, replies.size()); FindReplaceResponse findReplaceResponse = replies.get(1).getFindReplace(); assertEquals(100, findReplaceResponse.getOccurrencesChanged().intValue()); }
public BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title, String find, String replacement) throws IOException { Sheets service = this.service; List<Request> requests = new ArrayList<>(); requests.add(new Request() .setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest() .setProperties(new SpreadsheetProperties() .setTitle(title)) .setFields("title"))); requests.add(new Request() .setFindReplace(new FindReplaceRequest() .setFind(find) .setReplacement(replacement) .setAllSheets(true))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests); BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); FindReplaceResponse findReplaceResponse = response.getReplies().get(1).getFindReplace(); System.out.printf("%d replacements made.", findReplaceResponse.getOccurrencesChanged()); return response; }
SpreadsheetSnippets { public BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title, String find, String replacement) throws IOException { Sheets service = this.service; List<Request> requests = new ArrayList<>(); requests.add(new Request() .setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest() .setProperties(new SpreadsheetProperties() .setTitle(title)) .setFields("title"))); requests.add(new Request() .setFindReplace(new FindReplaceRequest() .setFind(find) .setReplacement(replacement) .setAllSheets(true))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests); BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); FindReplaceResponse findReplaceResponse = response.getReplies().get(1).getFindReplace(); System.out.printf("%d replacements made.", findReplaceResponse.getOccurrencesChanged()); return response; } }
SpreadsheetSnippets { public BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title, String find, String replacement) throws IOException { Sheets service = this.service; List<Request> requests = new ArrayList<>(); requests.add(new Request() .setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest() .setProperties(new SpreadsheetProperties() .setTitle(title)) .setFields("title"))); requests.add(new Request() .setFindReplace(new FindReplaceRequest() .setFind(find) .setReplacement(replacement) .setAllSheets(true))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests); BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); FindReplaceResponse findReplaceResponse = response.getReplies().get(1).getFindReplace(); System.out.printf("%d replacements made.", findReplaceResponse.getOccurrencesChanged()); return response; } SpreadsheetSnippets(Sheets service); }
SpreadsheetSnippets { public BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title, String find, String replacement) throws IOException { Sheets service = this.service; List<Request> requests = new ArrayList<>(); requests.add(new Request() .setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest() .setProperties(new SpreadsheetProperties() .setTitle(title)) .setFields("title"))); requests.add(new Request() .setFindReplace(new FindReplaceRequest() .setFind(find) .setReplacement(replacement) .setAllSheets(true))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests); BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); FindReplaceResponse findReplaceResponse = response.getReplies().get(1).getFindReplace(); System.out.printf("%d replacements made.", findReplaceResponse.getOccurrencesChanged()); return response; } SpreadsheetSnippets(Sheets service); String create(String title); BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title,
                                                      String find, String replacement); ValueRange getValues(String spreadsheetId, String range); BatchGetValuesResponse batchGetValues(String spreadsheetId, List<String> _ranges); UpdateValuesResponse updateValues(String spreadsheetId, String range,
                                             String valueInputOption, List<List<Object>> _values); BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range,
                                                       String valueInputOption,
                                                       List<List<Object>> _values); AppendValuesResponse appendValues(String spreadsheetId, String range,
                                             String valueInputOption, List<List<Object>> _values); BatchUpdateSpreadsheetResponse pivotTables(String spreadsheetId); BatchUpdateSpreadsheetResponse conditionalFormat(String spreadsheetId); }
SpreadsheetSnippets { public BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title, String find, String replacement) throws IOException { Sheets service = this.service; List<Request> requests = new ArrayList<>(); requests.add(new Request() .setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest() .setProperties(new SpreadsheetProperties() .setTitle(title)) .setFields("title"))); requests.add(new Request() .setFindReplace(new FindReplaceRequest() .setFind(find) .setReplacement(replacement) .setAllSheets(true))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests); BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); FindReplaceResponse findReplaceResponse = response.getReplies().get(1).getFindReplace(); System.out.printf("%d replacements made.", findReplaceResponse.getOccurrencesChanged()); return response; } SpreadsheetSnippets(Sheets service); String create(String title); BatchUpdateSpreadsheetResponse batchUpdate(String spreadsheetId, String title,
                                                      String find, String replacement); ValueRange getValues(String spreadsheetId, String range); BatchGetValuesResponse batchGetValues(String spreadsheetId, List<String> _ranges); UpdateValuesResponse updateValues(String spreadsheetId, String range,
                                             String valueInputOption, List<List<Object>> _values); BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range,
                                                       String valueInputOption,
                                                       List<List<Object>> _values); AppendValuesResponse appendValues(String spreadsheetId, String range,
                                             String valueInputOption, List<List<Object>> _values); BatchUpdateSpreadsheetResponse pivotTables(String spreadsheetId); BatchUpdateSpreadsheetResponse conditionalFormat(String spreadsheetId);  }