I am using this url:
https://docs.google.com/spreadsheets/u/1/d/e/2PACX-XXXX/pubhtml?gid=XXXX&single=true
I have checked "https://developers.google.com/sheets/api/quickstart/dotnet" but I am not able to find the spreadsheet id using which I can read the data.
I am using .net core 3.1
this is my code:
var credential = GoogleCredential.FromStream(new
FileStream(_hostEnvironment.ContentRootPath +
@"/Helper/CLient_secret.json", FileMode.Open)).CreateScoped();
var service = new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "",
});
// Define request parameters.
String spreadsheetId = "XXXX";
String range = "Sheet1!A1:ZZ";//Sheet1 refers to all the cells in Sheet1.
SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(spreadsheetId, range);
ValueRange response = request.Execute();
IList<IList<Object>> values = response.Values;
I also have tried other spreadsheets using this code, it reads successfully but the URL pattern was different from above mentioned URL.
For Ex:
https://docs.google.com/spreadsheets/d/ID#edit
I am not sure I am able to explain it properly or not