Badge Name | Status | Site |
---|---|---|
Latest Build Status | GitHub Repo | |
RaptorSheets.Gig Nuget Pkg | Raptor Sheets - Gig |
This project is a library designed to manage interactions between a custom API service and the Google Sheets API. It offers the following features:
- Provides extension methods for handling column and index assignments, either individually or in batches, with automatic processing
- Read data in any order by using column names as keys for easy access
- Apply data formatting, configure drop-downs, and set protection
- Configure alternating row colors and enable full sheet protection
- Assign names and colors to sheet tabs
- Appending data to specified sheets
- Retrieving data from all sheets (individually, in groups, or in batches)
- Retrieving spreadsheet properties, such as the title and sheet tab names
To authenticate, you can use one of the following methods:
Using the GoogleSheetManager
allows you to skip referencing Google.Apis.Sheets.v4
package and just call the functions and receive data with common objects.
Create a new instance of the GoogleSheetManager
with auth mode and spreadsheet id
var googleSheetManager = new GoogleSheetManager(authMode, spreadsheetId);
You can create all sheets, formats, and layouts in a new worksheet by calling CreateSheets()
await googleSheetManager.CreateSheets();
You can get all sheets and information by calling GetSheets()
var data = await googleSheetManager.GetSheets();
You can retrieve specific sheets and information by calling GetSheets()
and passing in the sheet enums you want.
var sheets = [SheetEnum.Sheet1, SheetEnum.Sheet2]
var data = await googleSheetManager.GetSheets(sheets);
Using the GoogleSheetService
allows you to change format, colors, and other options by referencing the Google.Apis.Sheets.v4
package.
You'll need to create your own service account and use the credentials to access your Google Sheet:
- Google Cloud Console
- Create New Project or use existing one
- Visit API Library and enable Google Sheets API
- APIs & Services -> Create Credentials -> Service Accounts
- Give the service account a
name
andid
- Once created select the service account and go to the
Keys
tab - Add/Create a new key and select type
JSON
- The key will download to your computer where you will have access to the values needed for the properties below.
Add Google JSON Credentials
by right clicking on RaptorSheets.Test
and selecting Manage User Secrets
(secrets.json)
Add the following JSON properties to it:
{
"google_credentials": {
"type": "service_account",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
},
"spreadsheets": {
"gig": "",
"stock": ""
}
}
Create new spreadsheets and add the service account/client email to it.
Update the user secrets with the spreadsheeet ids.
Once that is completed you'll be able to run all tests including integration tests.