public static void appendEmptyColumn(string spreadsheetId = "1rkEhkGsitr3VhKayIJpvdoUsIYOPfJUNimMD09CkMuE", int sheetId = 0) { // The A1 notation of a range to search for a logical table of data. // Values will be appended after the last row of the table. // string range = "1 - Performance Test Results"; // TODO: Update placeholder value. //"'1 - Performance Test Results'!A:G" // The ID of the spreadsheet to update. SheetsService sheetsService = new SheetsService(new BaseClientService.Initializer { HttpClientInitializer = GetCredential(), ApplicationName = "RaveReportAutomationUtility", }); Data.Request reqBody = new Data.Request { AppendDimension = new Data.AppendDimensionRequest { SheetId = sheetId, Dimension = "COLUMNS", Length = 1 } }; List <Data.Request> requests = new List <Data.Request>(); requests.Add(reqBody); // TODO: Assign values to desired properties of `requestBody`: Data.BatchUpdateSpreadsheetRequest requestBody = new Data.BatchUpdateSpreadsheetRequest(); requestBody.Requests = requests; SpreadsheetsResource.BatchUpdateRequest request = sheetsService.Spreadsheets.BatchUpdate(requestBody, spreadsheetId); //SpreadsheetsResource.BatchUpdateRequest request = sheetsService.Spreadsheets.BatchUpdate(requestBody, spreadsheetId); // To execute asynchronously in an async method, replace `request.Execute()` as shown: Data.BatchUpdateSpreadsheetResponse response = request.Execute(); // Data.BatchUpdateSpreadsheetResponse response = await request.ExecuteAsync(); // TODO: Change code below to process the `response` object: //Console.WriteLine(JsonConvert.SerializeObject(response)); // SpreadsheetsResource.ValuesResource.AppendRequest request = // sheetsService.Spreadsheets.Values.Append(body, spreadsheetId, range); // request.InsertDataOption = SpreadsheetsResource.ValuesResource.AppendRequest.InsertDataOptionEnum.INSERTROWS; //request.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.RAW; //var response = request.Execute(); }
public static async System.Threading.Tasks.Task InsertColumnNoteAsync(SheetsService service, string spreadsheetId, int sheetId, int columnNo, string comment) { try { var gridRange = new Google.Apis.Sheets.v4.Data.GridRange { EndColumnIndex = columnNo + 1, StartColumnIndex = columnNo, EndRowIndex = 1, StartRowIndex = 0, SheetId = sheetId }; var request = new Google.Apis.Sheets.v4.Data.Request(); request.UpdateCells = new Google.Apis.Sheets.v4.Data.UpdateCellsRequest(); request.UpdateCells.Range = gridRange; request.UpdateCells.Fields = "note"; request.UpdateCells.Rows = new List <Google.Apis.Sheets.v4.Data.RowData>(); request.UpdateCells.Rows.Add(new Google.Apis.Sheets.v4.Data.RowData()); request.UpdateCells.Rows[0].Values = new List <Google.Apis.Sheets.v4.Data.CellData>(); request.UpdateCells.Rows[0].Values.Add(new Google.Apis.Sheets.v4.Data.CellData()); request.UpdateCells.Rows[0].Values[0].Note = comment; var requests = new List <Request>(); requests.Add(request); var requestBody = new Google.Apis.Sheets.v4.Data.BatchUpdateSpreadsheetRequest(); requestBody.Requests = requests; var batchRequest = service.Spreadsheets.BatchUpdate(requestBody, spreadsheetId); await batchRequest.ExecuteAsync().ConfigureAwait(false); } finally { await Throttler.ThrottleCheck().ConfigureAwait(false); } }
public static void mergeCells(int startCol, int startRow, string spreadsheetId = "1rkEhkGsitr3VhKayIJpvdoUsIYOPfJUNimMD09CkMuE", int sheetId = 0) { // The A1 notation of a range to search for a logical table of data. // Values will be appended after the last row of the table. //"'1 - Performance Test Results'!A:G" // The ID of the spreadsheet to update. // string spreadsheetId = spreadsheetIDTextbox.Text; //Impliment this for the input entered in the textbox SheetsService sheetsService = new SheetsService(new BaseClientService.Initializer { HttpClientInitializer = GetCredential(), ApplicationName = "RaveReportAutomationUtility", }); Data.Request reqBody = new Data.Request { MergeCells = new Data.MergeCellsRequest { Range = new Data.GridRange { SheetId = sheetId, StartRowIndex = startRow, EndRowIndex = startRow + 1, StartColumnIndex = startCol, EndColumnIndex = startCol + 9 }, MergeType = "MERGE_ROWS" } }; List <Data.Request> requests = new List <Data.Request>(); requests.Add(reqBody); // TODO: Assign values to desired properties of `requestBody`: Data.BatchUpdateSpreadsheetRequest requestBody = new Data.BatchUpdateSpreadsheetRequest(); requestBody.Requests = requests; SpreadsheetsResource.BatchUpdateRequest request = sheetsService.Spreadsheets.BatchUpdate(requestBody, spreadsheetId); //SpreadsheetsResource.BatchUpdateRequest request = sheetsService.Spreadsheets.BatchUpdate(requestBody, spreadsheetId); // To execute asynchronously in an async method, replace `request.Execute()` as shown: Data.BatchUpdateSpreadsheetResponse response = request.Execute(); // Data.BatchUpdateSpreadsheetResponse response = await request.ExecuteAsync(); // TODO: Change code below to process the `response` object: //Console.WriteLine(JsonConvert.SerializeObject(response)); // SpreadsheetsResource.ValuesResource.AppendRequest request = // sheetsService.Spreadsheets.Values.Append(body, spreadsheetId, range); // request.InsertDataOption = SpreadsheetsResource.ValuesResource.AppendRequest.InsertDataOptionEnum.INSERTROWS; //request.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.RAW; //var response = request.Execute(); }