# Microsoft Excel

The **Microsoft Excel** integration enables you to automate spreadsheet tasks directly within your Dapta workflows. With these nodes, you can seamlessly read, write, and manage Excel files hosted on **OneDrive for Business** or **SharePoint**.

### 🚀 Key Capabilities

* **Read Data**: Retrieve rows with advanced filtering and pagination options.
* **Write Data**: Append new rows or update existing records efficiently.
* **Smart Sync (Upsert)**: Automatically create a row if it doesn't exist, or update it if it does.
* **Batch Operations**: Update or delete multiple rows matching specific criteria in a single step.
* **Formula Safe**: Updates strictly preserve existing formulas in your spreadsheets.

***

### ⚙️ Prerequisites

To use this integration, you need:

1. A **Microsoft 365 Business** or **School** account (OneDrive for Business / SharePoint).
2. An Excel file (`.xlsx`) stored in your OneDrive or SharePoint folder.
3. *Note: Personal OneDrive accounts (e.g., hotmail/outlook.com) may have limited compatibility.*

***

### 🔐 Authentication

To connect your Microsoft Excel account to Dapta, choose one of the following methods:

#### Option 1: Quick Connect (Recommended)

1. Add the **Microsoft Excel** node to your flow canvas.
2. Locate the **Credential** dropdown in the configuration panel.
3. Click the **+ (Plus)** button next to the dropdown.
4. Follow the Microsoft login prompt to authorize your account.
5. Your new credential will be automatically saved and selected.

#### Option 2: Settings Menu

1. Navigate to the [**Credentials Page**](https://app.dapta.ai/settings/oauth) in your Dapta dashboard.
2. Click **Add Credential** and select **Microsoft Excel** from the list.
3. Click **Connect** and sign in with your **Microsoft 365 Work or School account**.
4. Once connected, return to your flow and select this credential.

***

### 🛠️ Operations

#### 1. Get Rows

Retrieves data from a specific worksheet. Use filters to narrow down your results.

**Parameters**

* **Workbook** *(Dropdown, Required)* Select the source Excel file.
* **Worksheet** *(Dropdown, Required)* Select the specific sheet tab to read from.
* **Filters** *(List, Optional)* Define conditions to filter rows (e.g., `Status` = `Pending`). Multiple filters use **AND** logic.
* **Use Pagination** *(Boolean, Optional)* Enable this for processing large files in chunks.
* **Limit** *(Number, Optional)* Maximum rows to return per request (if pagination is enabled). Default: `100`.
* **Offset** *(Number, Optional)* Number of rows to skip (if pagination is enabled). Essential for looping through datasets.

**Output Example**

```json
{
  "results": 2,
  "values": [
    {
      "row_number": 2,
      "Name": "Alice Smith",
      "Email": "alice@example.com",
      "Status": "Active"
    },
    {
      "row_number": 5,
      "Name": "Bob Jones",
      "Email": "bob@example.com",
      "Status": "Active"
    }
  ],
  "pagination": {
    "enabled": true,
    "total": 50,
    "has_more": true
  }
}
```

***

#### 2. Append Row

Adds a new row to the bottom of the designated worksheet.

**Parameters**

* **Workbook** *(Dropdown, Required)* Select the Excel file.
* **Worksheet** *(Dropdown, Required)* Select the target sheet.
* **Values to Send** *(Map, Required)* Map your data to the specific Excel columns (e.g., Column `A` -> `{{name}}`).

{% hint style="info" %}
**Tip**: You can map values dynamically using variables from previous nodes. Unmapped columns will remain empty.
{% endhint %}

***

#### 3. Update Row

Modifies existing rows based on a search key. You can update a single match or all matching rows.

**Key Features**:

* **Formula Preservation**: Updating a value will trigger automatic recalculation of dependent formulas.
* **Partial Updates**: Only mapped columns are modified; others remain untouched.

**Parameters**

* **Workbook** *(Dropdown, Required)* Select the Excel file.
* **Worksheet** *(Dropdown, Required)* Select the target sheet.
* **Key Column** *(String, Required)* The column header to search in (e.g., `Email`).
* **Key Value** *(String, Required)* The value to search for (e.g., `alice@example.com`).
* **Values to Update** *(Map, Required)* The new data to write into the matching row(s).
* **Update All Matches** *(Boolean, Optional)*
  * `false` (Default): Updates only the **first** row found.
  * `true`: Updates **all** rows that match the Key Value.
* **Max Rows to Update** *(Number, Optional)* Safety limit for batch updates. Default: `1000`.

***

#### 4. Upsert Row (Update or Create)

The most robust way to sync data. It checks for a row's existence before acting:

* **Found?** → Updates the existing row.
* **Not Found?** → Creates a new row.

**Parameters**

Same parameters as **Update Row**. The `Key Column` and `Key Value` are used to check for existence.

***

#### 5. Delete Row

Removes rows from the file based on a match or a specific row number.

**Parameters**

* **Delete Mode** *(Select, Required)* Choose between `By Match` or `By Row Number`.
* **Key Column** *(String, Required)* (Match Mode) The column to search in.
* **Key Value** *(String, Required)* (Match Mode) The value to identify the row(s) to delete.
* **Row Number** *(Number, Required)* (Row Number Mode) The specific row index to delete (e.g., `5`).
* **Delete All Matches** *(Boolean, Optional)* If `true`, deletes **ALL** matching rows found. Use with caution.
* **Max Rows to Delete** *(Number, Optional)* Safety limit for batch deletion. Default: `1000`.

***

### 🚧 Usage Limits & Quotas

To ensure stability, the Microsoft Graph API imposes rate limits.

* **API Limits**: Processing thousands of rows in a rapid loop may trigger a `429 Too Many Requests` error.
* **Recommendation**: Always use **Pagination** for large datasets.
* **Tip**: If iterating through a large list, add a **Wait** node (e.g., 1-2 seconds) between loop iterations to prevent rate limiting.

***

### ❓ Troubleshooting

| Issue                  | Cause         | Solution                                                                          |
| ---------------------- | ------------- | --------------------------------------------------------------------------------- |
| **"Column not found"** | Case mismatch | Column names are case-sensitive. Ensure "Email" matches "Email" in Excel exactly. |
| **"File not found"**   | File moved    | If the file was renamed or moved in OneDrive, re-select it in the dropdown.       |
| **"Values are empty"** | Bad mapping   | Verify that your input variables (e.g., `{{step.data}}`) actually contain data.   |
| **Slow Performance**   | Large file    | Use **Pagination** or filters to limit the amount of data requested.              |

{% hint style="warning" %}
**Limit**: The API processes up to **10,000 rows** by default. For datasets larger than this, you **must** use pagination.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dapta.ai/integrations/microsoft-excel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
