public List <List <T> > GetValuesForCellsAt <T>(TableIndexRange range) { ValueRange result = SheetsService.Spreadsheets.Values .Get(SpreadsheetId, range.ToString()) .Execute(); if (result.Values.Count == 0) { throw new NonExistingIndexException(); } return((List <List <T> >)Convert.ChangeType( result.Values.Select(r => r.ToList()).ToList(), typeof(List <List <T> >))); }
public void SetValuesForCellsAt <T>(TableIndex index, List <List <T> > values) { var body = new ValueRange { Values = values.Select(v => v.Cast <object>().ToList()) .Cast <IList <object> >() .ToList(), MajorDimension = Direction.Horizontal.ToGoogleDimension() }; var range = new TableIndexRange(index, index .WithRow(index.Row + values.Count - 1) .WithColumn(index.Column + values.Select(v => v.Count).Max() - 1)); UpdateRequest request = SheetsService.Spreadsheets.Values.Update(body, SpreadsheetId, range.ToString()); request.ValueInputOption = USERENTERED; request.Execute(); }