예제 #1
0
        public async Task FormatUpdate(string spreadsheetId, RangePosition range, CellFormat userEnteredFormat)
        {
            //get sheet id by sheet name
            int sheetId = await getSheetID(spreadsheetId, range.TableName);

            //define cell color
            BatchUpdateSpreadsheetRequest bussr = new BatchUpdateSpreadsheetRequest();

            //create the update request for cells from the first row
            Request updateCellsRequest = new Request()
            {
                RepeatCell = new RepeatCellRequest()
                {
                    Range = range.GetGridRange(sheetId),
                    Cell  = new CellData()
                    {
                        UserEnteredFormat = userEnteredFormat
                    },
                    Fields = "UserEnteredFormat(BackgroundColor,TextFormat)"
                }
            };

            bussr.Requests = new List <Request>();
            bussr.Requests.Add(updateCellsRequest);

            SpreadsheetsResource.BatchUpdateRequest bur = _service.Spreadsheets.BatchUpdate(bussr, spreadsheetId);

            await autoAuthorize(bur);
        }