I would like to read a spreadsheet without knowing its range. Is that possible in C#? Or else I have to specify the range till the values are inserted in the sheet?
These things are dynamic in my requirement. The range can be at any limit so my code need to read the entered data from my sheet.
// Create Google Sheets API service.
SheetsService SheetsService = GetSheetsService();
// Here is my doubt.
// I have specified only the sheet name
// but I dont know the range which could be dynamic
var range = "Sheet3!";
SpreadsheetsResource.ValuesResource.GetRequest request =
SheetsService.Spreadsheets.Values.Get(SpreadSheetID, range);
var response = request.Execute();
return response;
The documentation for A1 notation (which is what the range is expressed in) includes:
Sheet1
refers to all the cells in Sheet1.
So if you really want all the cells, just use that, without a trailing !
. If you want to find out the size rather than getting the values, you may want the spreadsheets.get
rather than spreadsheets.values.get
method.
See more on this question at Stackoverflow