GoogleSheets

Connection and Sheet Selection

Methods for authenticating with Google Sheets, selecting a spreadsheet and sheet, and obtaining the Sheets object.

Methods for authenticating with Google Sheets, selecting a spreadsheet and sheet, and obtaining the Sheets object.

WithCredentials supplies the Google API credentials - build them with GPAL.Credentials using a service account key and the GoogleSheets OAuth scope. WithSpreadsheet selects the target spreadsheet by its ID or title. WithSheet selects the target worksheet within the spreadsheet by name or numeric index. ToGPALObject returns the IGoogleSheets interface for storage or injection.

Examples

GPAL Fluent: High-level fluent C# API

//WithSpreadsheet accepts either the spreadsheet ID (from the URL) or the spreadsheet title. WithSheet accepts a sheet name string or a zero-based integer index.

// Connect to a spreadsheet var sheets = GPAL.GoogleSheets .WithCredentials(GPAL.CredentialsFor(CredentialServiceType.Google) .WithUsername("you@example.com") .WithPassword("your-password") .WithServiceAccountKey(GPAL.FileFor("service-account.json")) .WithScope(OAuthScope.Google_Sheets) .ToGPALObject()) .WithSpreadsheet("1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms") .WithSheet("Sheet1") .ToGPALObject(); // List all sheets in a spreadsheet GPAL.GoogleSheets .WithCredentials(googleCreds) .WithSpreadsheet("spreadsheet-id") .ListSheets(out var sheetList);