private static async System.Threading.Tasks.Task <string> CreateNewWorkBookAsync(SheetsService service) { try { Spreadsheet requestBody = new Spreadsheet(); requestBody.Properties = new SpreadsheetProperties(); requestBody.Properties.Title = "Service Directory Generated: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");; SpreadsheetsResource.CreateRequest request = service.Spreadsheets.Create(requestBody); Spreadsheet response = await request.ExecuteAsync().ConfigureAwait(false); return(response.SpreadsheetId); } finally { await Throttler.ThrottleCheck().ConfigureAwait(false); } }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="sheetTitle"></param> /// <returns></returns> public async Task <Spreadsheet> CreateAsync(string title, string sheetTitle) { var requestBody = new Spreadsheet { Properties = new SpreadsheetProperties { Title = title }, Sheets = new List <Sheet> { new Sheet { Properties = new SheetProperties { Title = sheetTitle, TabColor = new Color { Red = 0.9F, Green = 0.1F, Blue = 0.1F, Alpha = 0.7F }, GridProperties = new GridProperties { ColumnCount = 50 } } } } }; SpreadsheetsResource.CreateRequest createRequest = _sheetsService.Spreadsheets.Create(requestBody); Spreadsheet createResponse = await createRequest.ExecuteAsync(); return(createResponse); }