Ejemplo n.º 1
0
        public AppendValuesResponse Append(string range, ValueRange body)
        {
            AppendRequest request = _service.Spreadsheets.Values.Append(body, SheetId(), range);

            request.ValueInputOption = AppendRequest.ValueInputOptionEnum.USERENTERED;
            return(request.Execute());
        }
        private void WriteActivityLogRowsToSheet(SheetsService service, List <IList <object> > rows)
        {
            CreateLogSheet(service);

            AppendRequest appendRequest = service.Spreadsheets.Values.Append(new ValueRange {
                Values = rows
            }, Spreadsheet, "PixelBotLog!A2:E");

            appendRequest.InsertDataOption = AppendRequest.InsertDataOptionEnum.INSERTROWS;
            appendRequest.ValueInputOption = AppendRequest.ValueInputOptionEnum.USERENTERED;
            _ = appendRequest.Execute();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adiciona os valores informados na planilha.
        /// </summary>
        /// <param name="values">Os valores da linha a ser adicionada.</param>
        /// <returns>Resposta do request da operação.</returns>
        public AppendValuesResponse AddValues(List <object> values)
        {
            ValueRange valueRange = new ValueRange();

            valueRange.Values = new List <IList <object> > {
                values
            };

            AppendRequest appendRequest = service.Spreadsheets.Values.Append(valueRange, spreadsheetId, "A:A");

            appendRequest.ValueInputOption = AppendRequest.ValueInputOptionEnum.USERENTERED;

            return(appendRequest.Execute());
        }
        private void CreateLogSheet(SheetsService service)
        {
            // Only run this the first time
            if (!_First)
            {
                return;
            }
            _First = false;

            var thisSpreadsheet = service.Spreadsheets.Get(Spreadsheet).Execute();

            if (!thisSpreadsheet.Sheets.Any(s => s.Properties.Title == "PixelBotLog"))
            {
                var newSheetRequest = new AddSheetRequest()
                {
                    Properties = new SheetProperties
                    {
                        Title = "PixelBotLog"
                    }
                };
                service.Spreadsheets.BatchUpdate(
                    new BatchUpdateSpreadsheetRequest
                {
                    Requests = new[] {
                        new Request {
                            AddSheet = newSheetRequest
                        }
                    }
                }, Spreadsheet).Execute();

                var newRecords = new List <IList <object> >();
                var newRow     = new List <object>();
                newRow.Add("Date");
                newRow.Add("Acting User");
                newRow.Add("Record Updated");
                newRow.Add("Command");
                newRow.Add("Pixels Changed");

                newRecords.Add(newRow);
                AppendRequest appendRequest = service.Spreadsheets.Values.Append(new ValueRange {
                    Values = newRecords
                }, Spreadsheet, "PixelBotLog!A1:E");
                appendRequest.InsertDataOption = AppendRequest.InsertDataOptionEnum.INSERTROWS;
                appendRequest.ValueInputOption = AppendRequest.ValueInputOptionEnum.USERENTERED;
                _ = appendRequest.Execute();
            }
        }
Ejemplo n.º 5
0
        public void AppendToSheet(Note note, string spreadsheetID, string sheetRange, string attachmentsFolderLink)
        {
            string spreadsheetId = spreadsheetID;
            string range         = sheetRange;

            AppendRequest.ValueInputOptionEnum valueInputOption = AppendRequest.ValueInputOptionEnum.USERENTERED;
            AppendRequest.InsertDataOptionEnum insertDataOption = AppendRequest.InsertDataOptionEnum.INSERTROWS;

            var arr = new string[] { note.NoteType, note.NoteContent, note.NoteRecordtime, attachmentsFolderLink };

            RequestBody.Values = new List <IList <object> > {
                arr
            };

            Request = service.Spreadsheets.Values.Append(RequestBody, spreadsheetId, range);
            Request.ValueInputOption = valueInputOption;
            Request.InsertDataOption = insertDataOption;

            Request.Execute();
        }