Update a Cell with C# and Sheets API v4

前端 未结 6 883
甜味超标
甜味超标 2020-12-15 18:33

Does anyone have a good C# example for updating a cell with the v4 API?

I have the get cell values c# example from the developer website working with Google Sheets A

6条回答
  •  -上瘾入骨i
    2020-12-15 19:18

    If you are using this tutorial https://developers.google.com/sheets/quickstart/dotnet Ensure you comment out the following line of code.

    credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
    

    Also this is what I used syntax wise and got it working.

    String spreadsheetId2 = "";
    String range2 = "!F5";
    ValueRange valueRange = new ValueRange();
    valueRange.MajorDimension = "COLUMNS";//"ROWS";//COLUMNS
    
    var oblist = new List() { "ello" };
    valueRange.Values = new List> { oblist };
    
    SpreadsheetsResource.ValuesResource.UpdateRequest update = service.Spreadsheets.Values.Update(valueRange, spreadsheetId2, range2);
    update.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
    UpdateValuesResponse result2 = update.Execute(); 
    
        

    提交回复
    热议问题