Skip to content

khanjal/RaptorSheets

Repository files navigation

RaptorSheets

Badge Name Status Site
Latest Build Status build status GitHub Repo
RaptorSheets.Gig Nuget Pkg Nuget Raptor Sheets - Gig

Project Description

This project is a library designed to manage interactions between a custom API service and the Google Sheets API. It offers the following features:

Header Management

  • 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

Column Formatting

  • Apply data formatting, configure drop-downs, and set protection

Sheet Styling

  • Configure alternating row colors and enable full sheet protection
  • Assign names and colors to sheet tabs

Other Features

  • 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

Using Library

Auth Modes

To authenticate, you can use one of the following methods:

Simple

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);

Advanced

Using the GoogleSheetService allows you to change format, colors, and other options by referencing the Google.Apis.Sheets.v4 package.

Testing

Create Service Account

You'll need to create your own service account and use the credentials to access your Google Sheet:

Local Setup

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.