public void Backup <T>() { int sheetId = GetSheetIdByNameClass(typeof(T).Name); CopySheetToAnotherSpreadsheetRequest requestBody = new CopySheetToAnotherSpreadsheetRequest(); requestBody.DestinationSpreadsheetId = SpreadsheetId; SpreadsheetsResource.SheetsResource.CopyToRequest request = Service.Spreadsheets.Sheets.CopyTo(requestBody, SpreadsheetId, sheetId); // To execute asynchronously in an async method, replace `request.Execute()` as shown: SheetProperties response = request.Execute(); // Data.SheetProperties response = await request.ExecuteAsync(); // TODO: Change code below to process the `response` object: var json = JsonConvert.SerializeObject(response); }
public static void ShablonDuplicater(int shID, string title) { CopySheetToAnotherSpreadsheetRequest requestBody = new CopySheetToAnotherSpreadsheetRequest { DestinationSpreadsheetId = SpreadsheetId }; SpreadsheetsResource.SheetsResource.CopyToRequest request = service.Spreadsheets.Sheets.CopyTo(requestBody, SpreadsheetId, shID); SheetProperties response = request.Execute(); BatchUpdateSpreadsheetRequest requestBodyBU = new BatchUpdateSpreadsheetRequest(); IList <Request> LQReq = new List <Request>(); LQReq.Add(google_requests.RenamerSh(response.SheetId, title)); requestBodyBU.Requests = LQReq; BatchUpdateRequest BUrequest = service.Spreadsheets.BatchUpdate(requestBodyBU, SpreadsheetId); var resp2 = BUrequest.Execute(); newSheetId = response.SheetId ?? 0; }
public SheetProperties CopySheets(string ClientId, string ClientSecret, string destinationSpreadsheetId, string sourceSpreadsheetId, int sourceSheetId) { var sheetsService = GoogleAPI.GetSheetsService(ClientId, ClientSecret); CopySheetToAnotherSpreadsheetRequest requestBody = new CopySheetToAnotherSpreadsheetRequest(); requestBody.DestinationSpreadsheetId = destinationSpreadsheetId; SpreadsheetsResource.SheetsResource.CopyToRequest request = sheetsService.Spreadsheets.Sheets.CopyTo(requestBody, sourceSpreadsheetId, sourceSheetId); // To execute asynchronously in an async method, replace `request.Execute()` as shown: SheetProperties response = request.Execute(); // Data.SheetProperties response = await request.ExecuteAsync(); // TODO: Change code below to process the `response` object: Console.WriteLine(JsonConvert.SerializeObject(response)); return(response); }