Search in sources :

Example 1 with CopyPasteRequest

use of com.google.api.services.sheets.v4.model.CopyPasteRequest in project tutorials by eugenp.

the class GoogleSheetsIntegrationTest method whenUpdateSpreadSheetTitle_thenOk.

@Test
public void whenUpdateSpreadSheetTitle_thenOk() throws IOException {
    UpdateSpreadsheetPropertiesRequest updateRequest = new UpdateSpreadsheetPropertiesRequest().setFields("*").setProperties(new SpreadsheetProperties().setTitle("Expenses"));
    CopyPasteRequest copyRequest = new CopyPasteRequest().setSource(new GridRange().setSheetId(0).setStartColumnIndex(0).setEndColumnIndex(2).setStartRowIndex(0).setEndRowIndex(1)).setDestination(new GridRange().setSheetId(1).setStartColumnIndex(0).setEndColumnIndex(2).setStartRowIndex(0).setEndRowIndex(1)).setPasteType("PASTE_VALUES");
    List<Request> requests = new ArrayList<>();
    requests.add(new Request().setCopyPaste(copyRequest));
    requests.add(new Request().setUpdateSpreadsheetProperties(updateRequest));
    BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests);
    sheetsService.spreadsheets().batchUpdate(SPREADSHEET_ID, body).execute();
}
Also used : CopyPasteRequest(com.google.api.services.sheets.v4.model.CopyPasteRequest) UpdateSpreadsheetPropertiesRequest(com.google.api.services.sheets.v4.model.UpdateSpreadsheetPropertiesRequest) SpreadsheetProperties(com.google.api.services.sheets.v4.model.SpreadsheetProperties) BatchUpdateSpreadsheetRequest(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest) GridRange(com.google.api.services.sheets.v4.model.GridRange) BatchUpdateSpreadsheetRequest(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest) UpdateSpreadsheetPropertiesRequest(com.google.api.services.sheets.v4.model.UpdateSpreadsheetPropertiesRequest) BatchUpdateValuesRequest(com.google.api.services.sheets.v4.model.BatchUpdateValuesRequest) Request(com.google.api.services.sheets.v4.model.Request) CopyPasteRequest(com.google.api.services.sheets.v4.model.CopyPasteRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

BatchUpdateSpreadsheetRequest (com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest)1 BatchUpdateValuesRequest (com.google.api.services.sheets.v4.model.BatchUpdateValuesRequest)1 CopyPasteRequest (com.google.api.services.sheets.v4.model.CopyPasteRequest)1 GridRange (com.google.api.services.sheets.v4.model.GridRange)1 Request (com.google.api.services.sheets.v4.model.Request)1 SpreadsheetProperties (com.google.api.services.sheets.v4.model.SpreadsheetProperties)1 UpdateSpreadsheetPropertiesRequest (com.google.api.services.sheets.v4.model.UpdateSpreadsheetPropertiesRequest)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1