@Test public void testBatchUpdateValues() throws IOException { String spreadsheetId = this.createTestSpreadsheet(); List<List<Object>> values = Arrays.asList( Arrays.asList("A", "B"), Arrays.asList("C", "D")); BatchUpdateValuesResponse result = this.snippets.batchUpdateValues(spreadsheetId, "A1:B2", "USER_ENTERED", values); assertEquals(1, result.getResponses().size()); assertEquals(2, result.getTotalUpdatedRows().intValue()); assertEquals(2, result.getTotalUpdatedColumns().intValue()); assertEquals(4, result.getTotalUpdatedCells().intValue()); }
public BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range, String valueInputOption, List<List<Object>> _values) throws IOException { Sheets service = this.service; List<List<Object>> values = Arrays.asList( Arrays.asList( ) ); values = _values; List<ValueRange> data = new ArrayList<>(); data.add(new ValueRange() .setRange(range) .setValues(values)); BatchUpdateValuesRequest body = new BatchUpdateValuesRequest() .setValueInputOption(valueInputOption) .setData(data); BatchUpdateValuesResponse result = service.spreadsheets().values().batchUpdate(spreadsheetId, body).execute(); System.out.printf("%d cells updated.", result.getTotalUpdatedCells()); return result; }
SpreadsheetSnippets { public BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range, String valueInputOption, List<List<Object>> _values) throws IOException { Sheets service = this.service; List<List<Object>> values = Arrays.asList( Arrays.asList( ) ); values = _values; List<ValueRange> data = new ArrayList<>(); data.add(new ValueRange() .setRange(range) .setValues(values)); BatchUpdateValuesRequest body = new BatchUpdateValuesRequest() .setValueInputOption(valueInputOption) .setData(data); BatchUpdateValuesResponse result = service.spreadsheets().values().batchUpdate(spreadsheetId, body).execute(); System.out.printf("%d cells updated.", result.getTotalUpdatedCells()); return result; } }
SpreadsheetSnippets { public BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range, String valueInputOption, List<List<Object>> _values) throws IOException { Sheets service = this.service; List<List<Object>> values = Arrays.asList( Arrays.asList( ) ); values = _values; List<ValueRange> data = new ArrayList<>(); data.add(new ValueRange() .setRange(range) .setValues(values)); BatchUpdateValuesRequest body = new BatchUpdateValuesRequest() .setValueInputOption(valueInputOption) .setData(data); BatchUpdateValuesResponse result = service.spreadsheets().values().batchUpdate(spreadsheetId, body).execute(); System.out.printf("%d cells updated.", result.getTotalUpdatedCells()); return result; } SpreadsheetSnippets(Sheets service); }
SpreadsheetSnippets { public BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range, String valueInputOption, List<List<Object>> _values) throws IOException { Sheets service = this.service; List<List<Object>> values = Arrays.asList( Arrays.asList( ) ); values = _values; List<ValueRange> data = new ArrayList<>(); data.add(new ValueRange() .setRange(range) .setValues(values)); BatchUpdateValuesRequest body = new BatchUpdateValuesRequest() .setValueInputOption(valueInputOption) .setData(data); BatchUpdateValuesResponse result = service.spreadsheets().values().batchUpdate(spreadsheetId, body).execute(); System.out.printf("%d cells updated.", result.getTotalUpdatedCells()); return result; } 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 BatchUpdateValuesResponse batchUpdateValues(String spreadsheetId, String range, String valueInputOption, List<List<Object>> _values) throws IOException { Sheets service = this.service; List<List<Object>> values = Arrays.asList( Arrays.asList( ) ); values = _values; List<ValueRange> data = new ArrayList<>(); data.add(new ValueRange() .setRange(range) .setValues(values)); BatchUpdateValuesRequest body = new BatchUpdateValuesRequest() .setValueInputOption(valueInputOption) .setData(data); BatchUpdateValuesResponse result = service.spreadsheets().values().batchUpdate(spreadsheetId, body).execute(); System.out.printf("%d cells updated.", result.getTotalUpdatedCells()); return result; } 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);  }