I’m looking for a C# approach using the Google Sheets API to list every sheet’s name and ID.
Below is a sample code:
var authInfo = CredentialLoader.Load("config.json");
var sheetClient = new SheetsConnector(authInfo, "AppInstance");
var allSheets = sheetClient.FetchAllSheets("sampleSpreadsheetId");
hey, you might wanna use the sheets metadata api, it spits out all sheet properties directly. then u can loop thru to grab id & name. havent used that exact method but seems a bit simpler. good luck!
I have been working on similar projects and found that determining the best method of retrieving all sheets from a spreadsheet can depend on context. When dealing with the Google Sheets API in C#, I discovered that using the metadata from the spreadsheet resource brought more clarity than parsing document contents. Though the initial setup can be a bit verbose with proper authentication and setup, once that is established, it makes retrieval straightforward. In contrast to other approaches that might require multiple API calls, this method strips down operations nicely.