# Excel

## How to Use the Excel Node

To use the Excel node, simply add it to your StackAI workflow and configure it to perform actions such as writing data to a spreadsheet. You can connect it to other nodes (like LLMs, input nodes, or data sources) to automate the flow of information into your Excel files. The node supports secure authentication via connection IDs, ensuring your data remains protected. Alternatively, you can also add Excel as a tool for your LLM to use.

***

## Example of Usage

Suppose you want to automatically log survey responses from a form into an Excel spreadsheet stored in SharePoint. You can connect the input node (collecting responses) to the Excel node, which then writes each new entry into the designated spreadsheet, eliminating manual data entry.

***

## Available Actions for the Excel Node

Currently, we support 17 different actions for the Excel node in StackAI:

<table><thead><tr><th width="177.33203125">Action</th><th>Description</th></tr></thead><tbody><tr><td><strong>Write to Sheet</strong></td><td>Automatically writes data to a specified Excel sheet in SharePoint or OneDrive.</td></tr><tr><td><strong>Create Workbook</strong></td><td>Create a new Excel workbook in a specified SharePoint site or OneDrive location. You can specify the workbook name and optional folder path.</td></tr><tr><td><strong>List Workbooks</strong></td><td>Retrieve a list of all Excel workbooks available in a SharePoint site or OneDrive. Returns workbook details and count.</td></tr><tr><td><strong>Create Sheet</strong></td><td>Create a new worksheet/tab within an existing workbook in SharePoint or OneDrive.</td></tr><tr><td><strong>Delete Sheet</strong></td><td>Completely remove a worksheet from a workbook.</td></tr><tr><td><strong>Clear Sheet</strong></td><td>Remove all data from a worksheet while keeping the sheet itself. Optionally clear only a specific range.</td></tr><tr><td><strong>List Sheets</strong></td><td>Retrieve a list of all worksheets in a workbook, including sheet count.</td></tr><tr><td><strong>Read from Sheet</strong></td><td>Read data from a worksheet.</td></tr><tr><td><strong>Update Cell</strong></td><td>Update a single cell with a new value (text, number, formula, or clear it).</td></tr><tr><td><strong>Get Sheet by ID</strong></td><td>Find a specific worksheet by its unique ID or by name. Returns worksheet details including position and visibility.</td></tr><tr><td><strong>Rename Sheet</strong></td><td>Change the name of an existing worksheet (find by name or index).</td></tr><tr><td><strong>Create Table</strong></td><td>Create a new formatted Excel table within a worksheet. Specify data, starting cell, and optional table range.</td></tr><tr><td><strong>Add Data to Table</strong></td><td>Append new rows of data to an existing Excel table.</td></tr><tr><td><strong>Update Row</strong></td><td>Update an existing row with new values at a specified row index.</td></tr><tr><td><strong>Find Row</strong></td><td>Search for rows containing a specific value. Supports column filtering and case-sensitive search.</td></tr><tr><td><strong>Get Cells in Range</strong></td><td>Read cell value(s) from a specific range (single cell, rectangular range, entire column, or row).</td></tr><tr><td><strong>Get Row by Index</strong></td><td>Get a specific row by its row number from an Excel worksheet (1-based). Specify column range (e.g., A to Z).</td></tr></tbody></table>

### Example: Write to Sheet

**Description:**\
Automatically writes data to a specified Excel sheet in SharePoint or OneDrive.

#### Connect Excel&#x20;

Establish a new connection or using an existing connection to SharePoint or OneDrive.

#### Inputs

<table><thead><tr><th width="161.98828125">Name</th><th width="298.625">Description</th><th width="106.8125">Required</th><th width="188.5625">Input Type</th></tr></thead><tbody><tr><td><strong>Site</strong></td><td>Select the site from your connection (OneDrive or SharePoint)</td><td>Yes</td><td>Select from dropdown</td></tr><tr><td><strong>Workbook</strong></td><td>Select the Excel workbook</td><td>Yes</td><td>Select from dropdown or search</td></tr><tr><td><strong>Sheet</strong></td><td>Enter the specific sheet name in the workbook</td><td>Yes</td><td>Select from dropdown</td></tr><tr><td><strong>Values</strong></td><td>Enter the values to write to the sheet (JSON)</td><td>Yes</td><td>Enter manually or use prior input nodes</td></tr><tr><td><strong>Target Range</strong></td><td>Starting cell or the explicit range to write data (e.g., A1:D10)</td><td>Yes</td><td>Enter manually or use prior input nodes</td></tr><tr><td><strong>Formulas</strong></td><td>2D array of formulas matching data dimensions</td><td>No</td><td>Enter manually or use prior input nodes</td></tr></tbody></table>

**Example Input:**

```json
{
    "site_id": "abc123",
    "sheet_name": "Test",
    "workbook_url": "Example",
    "data": "[[\"test 1\",\"1\"],[\"test 2\",\"2\"]]",
    "target_range": "A1:B2",
    "connection_id": "your-connection-id-here",
    "connector_type_id": "excel_sharepoint_oauth2"
 }
```

#### Outputs

<table><thead><tr><th width="139.546875">Name</th><th>Description</th></tr></thead><tbody><tr><td>Status</td><td>Status of the operation</td></tr><tr><td>Message</td><td>Message about the operation</td></tr></tbody></table>

**Example Output:**

```json
{
    "status": "Success",
    "message": "Successfully wrote 2 row(s) x 2 column(s) to range A1:B2 in sheet 'Test'"
  }
```

***

## Best Practices

* Always ensure your connection ID is valid and has the necessary permissions to access the target Excel file.
* Validate your data structure before writing to avoid errors.
* Use dynamic node references (e.g., {in-0}) to automate data flow from other nodes.

***

## Summary

The Excel node in StackAI is a powerful tool for automating spreadsheet operations in SharePoint. By leveraging its write capabilities, you can streamline data management, reduce manual work, and enhance collaboration across your team.
