Reputation: 23
I am working with Google Sheet API. I am facing problem to read cell Note. As below image, I am able to reading cell value i.e. "Ajay Gangwar", but not able to read cell note i.e. "Senior Software Engineer".
Below code working fine to read data from Google Sheet:
private static void readGoogleSheetNote(SheetsService sheetsService)
{
string spreadsheetId = "1FvPaJVu5z_Vml8eIqPK7q2WOWosOH-llL4p3FItg6Zo";
string range = "Sheet1";
SpreadsheetsResource.ValuesResource.GetRequest.ValueRenderOptionEnum valueRenderOption = (SpreadsheetsResource.ValuesResource.GetRequest.ValueRenderOptionEnum)0;
SpreadsheetsResource.ValuesResource.GetRequest.DateTimeRenderOptionEnum dateTimeRenderOption = (SpreadsheetsResource.ValuesResource.GetRequest.DateTimeRenderOptionEnum)0;
SpreadsheetsResource.ValuesResource.GetRequest getRequest = sheetsService.Spreadsheets.Values.Get(spreadsheetId, range);
getRequest.ValueRenderOption = valueRenderOption;
getRequest.DateTimeRenderOption = dateTimeRenderOption;
Google.Apis.Sheets.v4.Data.ValueRange response = getRequest.Execute();
Console.WriteLine(JsonConvert.SerializeObject(response));
Console.ReadKey();
}
The output of the above code is:
Upvotes: 2
Views: 785
Reputation: 2014
You have to use the Method: spreadsheets.get to get the cell notes, as seen on the Overview of Cells from this resource.
Using the following script you will get the data from the A4
cell. Inside the response there is the notes field:
String spreadsheetId = "SPREADSHEET ID";
String range = "Sheet1!A4";
bool includeGridData = true;
SpreadsheetsResource.GetRequest request = service.Spreadsheets.Get(spreadsheetId);
request.Ranges = range;
request.IncludeGridData = includeGridData;
Data.Spreadsheet response = request.Execute();
Console.WriteLine(JsonConvert.SerializeObject(response.Sheets));
Upvotes: 3