# OneDrive Excel Sheets

This data destination connector exports tables from your [Storage tables](https://help.keboola.com/storage/tables) as Excel sheets to 
[Microsoft OneDrive](https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage).

**[Microsoft OneDrive](https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage)**
cloud storage integrates
**[Office365](https://www.office.com/)**
and **[SharePoint](https://www.microsoft.com/en-us/microsoft-365/sharepoint/collaboration)** sites,
so with this connector you can write to any Excel sheet on your personal or business account.

The contents of the sheet can be overwritten or new lines can be added at the end.




**Before you start**

You need:

- **A Microsoft account with OneDrive** that you can authorize (/components/authorization/): a personal account, or a work or school (Office 365) account. To write to a SharePoint site, the account needs access to that site. The connector asks for the Microsoft Graph permissions `offline_access`, `User.Read`, `Files.ReadWrite.All` and `Sites.ReadWrite.All`. If your organization restricts user consent to apps, a Microsoft Entra admin must approve these permissions before the authorization succeeds.
- **An Excel workbook (XLSX)** to write to, or a path where the connector should create one (#create-a-new-workbook).

What each tab needs:

- **Prompt tab:** Kai, the **Kai Agent** button in the top bar, on supported stacks. A new Free Plan project has it from the start; elsewhere an organization admin turns it on once: Get started with Kai (/kai/getting-started/).
- **UI tab:** a browser.
- **CLI / API tab:** kbagent (/cli/getting-started/), connected to your project. The checks only read.



## Configuration
[Create a new configuration](https://help.keboola.com/components/configurations/#create-a-configuration) of the **OneDrive Excel Sheets** data destination connector.  
Then, click **Authorize Account** to [authorize the configuration](https://help.keboola.com/components/authorization/). 

Click **Add Table** to configure the export.

![Screenshot - Empty configuration](https://help.keboola.com/components/writers/storage/onedrive/onedrive-01.png)

Select a **Table** from your buckets and click **Add Table**.

![Screenshot - Add table popup](https://help.keboola.com/components/writers/storage/onedrive/onedrive-02.png)

**Use the file picker** to list accessible Excel files – workbooks.  
Alternatively, you can [create a new workbook](https://help.keboola.com/components/writers/storage/onedrive/#create-a-new-workbook).

![Screenshot - Use file picker](https://help.keboola.com/components/writers/storage/onedrive/onedrive-03.png)

Go through the list and select a file. Click **Open** to confirm the file you want to write to.

![Screenshot - Select file](https://help.keboola.com/components/writers/storage/onedrive/onedrive-04.png)

The target file is specified by **Drive ID** and **File ID**. They are automatically filled in.   
**File Name** is for your information only and its change doesn't affect functionality.

![Screenshot - Workbook config](https://help.keboola.com/components/writers/storage/onedrive/onedrive-05.png)

Click **Load Worksheets** to select a worksheet from the workbook configured in the previous step.  
Alternatively, you can [create a new worksheet](https://help.keboola.com/components/writers/storage/onedrive/#create-a-new-worksheet).

![Screenshot - Empty worksheet config](https://help.keboola.com/components/writers/storage/onedrive/onedrive-06.png)

In the list that appeared, **click the name** of the worksheet you want to set as the target.

![Screenshot - Select worksheet](https://help.keboola.com/components/writers/storage/onedrive/onedrive-07.png)

The worksheet is specified by **Worksheet ID**. It is automatically filled in.   
**Worksheet Name** is for your information only and its change doesn't affect functionality.

You can check the **Append** checkbox to append new rows after the existing ones;  
otherwise, the contents of the worksheet will be overwritten.

![Screenshot - Select worksheet](https://help.keboola.com/components/writers/storage/onedrive/onedrive-08.png)

Click **Save** when you're done.

![Screenshot - Select worksheet](https://help.keboola.com/components/writers/storage/onedrive/onedrive-09.png)

Then click **Run Component**.

**Check:**


### Prompt


```text title="Prompt" wrap
Did the last job of the OneDrive Excel Sheets data destination configuration my-onedrive-config end with success? Give its end time.
```

Kai only reads here, so it asks for no approval, and its answer links to what it found in your project.


### UI


The job ends with **Success**, and the worksheet in OneDrive holds the table's
rows: in place of the old contents, or below them if you checked **Append**.


### CLI / API


```bash
kbagent job list --component-id keboola.wr-onedrive --limit 1
```

If you have several configurations, add `--config-id` with yours; the job's `status` shows `success`, and then check the destination as in the UI tab.


---


## Modify Configuration
When a table is added to the connector, it is displayed in the list of tables. 

Configured tables are stored as [configuration rows](https://help.keboola.com/components/#configuration-rows).

![Screenshot - Save](https://help.keboola.com/components/writers/storage/onedrive/onedrive-10.png)

Each table has a different setting, but all tables share the same authorization to OneDrive account.

The list shows the row name, and the source table in [Storage](https://help.keboola.com/storage/).

You can **click the row to modify** the configuration.

## Create a New Workbook

You can create a new workbook instead of using the existing one. 

Click **Create Workbook**.

![Screenshot - Create workbook button](https://help.keboola.com/components/writers/storage/onedrive/onedrive-11.png)

Specify the full file **Path** and click **Create**.

![Screenshot - Create workbook popup](https://help.keboola.com/components/writers/storage/onedrive/onedrive-12.png)

**File Name**, **Drive ID**, and **File ID** are automatically filled in.

## Create a New Worksheet

You can create a new worksheet instead of using an existing one.

Click **Create Worksheet**.

![Screenshot - Create worksheet button](https://help.keboola.com/components/writers/storage/onedrive/onedrive-13.png)

Specify the worksheet's **Name** and click **Create**.

![Screenshot - Create worksheet popup](https://help.keboola.com/components/writers/storage/onedrive/onedrive-14.png)

**Worksheet Name**, and **Worksheet ID** are automatically filled in.
