/// <summary> /// Get information from a range in a spreadsheet /// </summary> /// <param name="spreadSheetId">Source spreadsheet ID</param> /// <param name="readRange">Range with information</param> /// <returns>Requested information</returns> /// <exception cref="AccessDeniedException">Thrown when had problem with there was an access problem with Google Drive</exception> private async Task <IList <IList <object> > > ReadInfoAsync(string spreadSheetId, string readRange) { try { var response = await _service.Spreadsheets.Values. Get(spreadSheetId, readRange).ExecuteAsync(); return(response?.Values); } catch (Exception e) { throw AccessDeniedException.CreateException(e); } }
/// <summary> /// Write information to a range in a spreadsheet /// </summary> /// <param name="info">Information to write</param> /// <param name="spreadSheetId">Source spreadsheet ID</param> /// <param name="writeRange">Range to write</param> /// <exception cref="AccessDeniedException">Thrown when had problem with there was an access problem with Google Drive</exception> private async Task WriteInfoAsync(IList <IList <object> > info, string spreadSheetId, string writeRange) { try { var valueRange = new ValueRange { Values = info }; var update = _service.Spreadsheets.Values.Update(valueRange, spreadSheetId, writeRange); update.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED; await update.ExecuteAsync(); } catch (Exception e) { throw AccessDeniedException.CreateException(e); } }