# Google sheets

## Overview

With Joule’s **Google Sheets connector**, you can seamlessly publish real-time events directly in to a spreadsheet.

Key features are:

1. <mark style="color:green;">**Real-time dashboards**</mark>\
   Keep your spreadsheets live: insert and update events in real time for dashboards.
2. <mark style="color:green;">**Spreadsheet analytics**</mark>\
   Enable deeper business analytics by streaming events directly into your desktop spreadsheets

{% hint style="info" %}
**Client library:** com.google.api-client:google-api-client:2.7.0
{% endhint %}

## Examples & DSL attributes

This configuration sets up the publisher to send events directly in a specified Google Spreadsheet.

```yaml
google sheets publisher:
  application name: Joule google sheets test
  spreadsheetId: 1PNhq2t7fJ8AqJBmlSvywdpI4maFaAaUC
  range: 'Blotter!A2'
  oauth:
      credentials filepath: /home/joule/credentials.json
```

## Setting up

{% stepper %}
{% step %}

### Setup google project and enable spreadsheet API

Create a [project](https://developers.google.com/workspace/guides/create-project) and enable Google Spreadsheet API.&#x20;
{% endstep %}

{% step %}

### Configure consent and download credentials&#x20;

To access the spreadsheet Joule needs the user credentials to be created and downloaded. This can be done from the [Google Developers Console](https://console.developers.google.com/). &#x20;
{% endstep %}

{% step %}

### Create the target spreadsheet

Create the target spreadsheet and copy the spreadsheet Id.

{% hint style="info" %}
Copy the spreadsheet id from the URL e.g. [https://docs.google.com/spreadsheets/d/**1PNhq2t7fJ8AqJBmlSvywdpI4maFaAaUC-BUTyIc8utg**](https://docs.google.com/spreadsheets/d/1PNhq2t7fJ8AqJBmlSvywdpI4maFaAaUC-BUTyIc8utg)
{% endhint %}
{% endstep %}

{% step %}

### Define and deploy sink configuration

```yaml
google sheets publisher:
  application name: Joule google sheets test
  spreadsheetId: 1PNhq2t7fJ8AqJBmlSvywdpI4maFaAaUC
  range: 'Blotter!A2'
  oauth:
      credentials filepath: /home/joule/credentials.json
```

{% endstep %}

{% step %}

### Now you are ready to publish events to the sheet

Deploy a use case that publishes events to the spreadsheet.
{% endstep %}
{% endstepper %}

{% hint style="success" %}
Follow the official google [documentation](https://developers.google.com/workspace/guides/configure-oauth-consent) for more information on setting up projects on GCP
{% endhint %}

### Attributes schema

<table><thead><tr><th width="178">Attribute</th><th width="281">Description</th><th width="191">Data Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>application name</td><td>Application name</td><td>String</td><td>true</td></tr><tr><td>spreadsheetId</td><td>Spreadsheet id that is embedded in the url.</td><td>String</td><td>true</td></tr><tr><td>range</td><td>Target sheet and start cell</td><td>String</td><td>true</td></tr><tr><td>oauth</td><td>OAuth configuration</td><td>String</td><td>true</td></tr></tbody></table>

### OAuth Attribute

<table><thead><tr><th width="178">Attribute</th><th width="281">Description</th><th width="191">Data Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>credentials filepath</td><td>Path to the google OAuth consent credentials file.</td><td>String</td><td>true</td></tr></tbody></table>

##
