> For the complete documentation index, see [llms.txt](https://docs.appstrategy.com/apprules-r-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/system-settings/data-sources/connection-settings/spreadsheets/excel.md).

# Excel

Connects to Microsoft Excel workbooks stored on the local file system, a network share, SharePoint Online or OneDrive for Business. Each worksheet is exposed as a table and can be queried and updated with SQL.

#### Connection Properties

**Connection**

| Property        | Default | Notes                                                                                                   |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------- |
| Excel File      | —       | Required. Local or UNC path, e.g. `C:\Data\Orders.xlsx`, or the full file URL for SharePoint / OneDrive |
| URI             | —       | Alternative to Excel File; used only when Excel File is empty                                           |
| Connection Type | `Local` | `Local`, `SharePoint REST` or `OneDrive`                                                                |
| Header          | `true`  | `true`: the first row holds the column names. `false`: columns are named `Column0`, `Column1`, …        |
| Define Tables   | —       | Extra table names for existing sheets, comma-separated: `Orders=Sheet1,Customers=Sheet2`                |
| Timeout         | `60`    | Download / upload timeout in seconds (SharePoint and OneDrive only)                                     |

Supported formats: `.xlsx`, `.xlsm`, `.xls` and `.xlsb` for reading; `.xlsx` and `.xlsm` for writing.

**Azure Authentication**

Required when **Connection Type** is `SharePoint REST` or `OneDrive`. The connector authenticates as a Microsoft Entra application (client credentials) and accesses the file through Microsoft Graph.

| Property            | Used by                   | Notes                                               |
| ------------------- | ------------------------- | --------------------------------------------------- |
| Azure Tenant        | SharePoint REST, OneDrive | Tenant ID or domain, e.g. `contoso.onmicrosoft.com` |
| OAuth Client Id     | SharePoint REST, OneDrive | Application (client) ID of the app registration     |
| OAuth Client Secret | SharePoint REST, OneDrive | Client secret of the app registration               |

The app registration needs the Microsoft Graph **application** permission `Sites.ReadWrite.All` or `Files.ReadWrite.All` (admin consent required).

How remote workbooks are handled:

* On open, the workbook is downloaded to a temporary working copy.
* All reads and writes run against that copy.
* On close, the copy is uploaded back if anything was changed, then deleted.
* The upload is refused, and no changes are saved, if the workbook was modified by someone else in the meantime or is locked because it is open in Excel.

**Data**

| Property              | Default       | Notes                                                                                                 |
| --------------------- | ------------- | ----------------------------------------------------------------------------------------------------- |
| Type Detection Scheme | `RowScan`     | `RowScan`: column types are detected from the cell values. `None`: no type detection                  |
| Skip Top              | `0`           | Number of rows to skip at the top of each sheet before reading                                        |
| Show Empty Rows       | `false`       | Include completely empty rows in the results                                                          |
| Null Value Mode       | `ReadAsNull`  | `ReadAsNull`: empty text values are returned as null. `ReadAsEmpty`: kept as empty text               |
| Empty Value Mode      | `ReadAsEmpty` | `ReadAsEmpty`: empty cells in text columns are returned as empty text. `ReadAsNull`: returned as null |
| Null Values           | —             | Comma-separated cell values to treat as null, e.g. `N/A,NULL,-`                                       |
| Max Rows              | `-1`          | Maximum number of rows returned by a query. `-1` = no limit                                           |
| Allow Formula         | `true`        | Values starting with `=` are written as formulas on INSERT / UPDATE                                   |
| Readonly              | `false`       | `true` blocks INSERT, UPDATE and DELETE                                                               |

**Logging**

| Property  | Default                                                                    | Notes                         |
| --------- | -------------------------------------------------------------------------- | ----------------------------- |
| Log Level | `0`                                                                        | `0` disabled, `1` log to file |
| Log File  | `%APPDATA%\appStrategy\PortalData\Default\Logs\Connectors\Excel_Debug.log` |                               |

#### Supported SQL

**Tables and columns**

* Every worksheet is a table. A sheet named `Orders` can be referenced as `Orders` or `Orders$`.
* Table and column names are not case-sensitive.
* Column names come from the first row (see **Header**). Excel has no primary keys, foreign keys or indexes.

**SELECT**

```sql
SELECT * FROM Orders
SELECT OrderId, Customer, Amount FROM Orders WHERE Amount > 1000 ORDER BY Amount DESC
SELECT * FROM Orders WHERE Country IN ('FR', 'IE') AND (Status = 'Open' OR Status IS NULL) LIMIT 50
```

| Clause   | Supported                                                        |
| -------- | ---------------------------------------------------------------- |
| Columns  | `*` or a list of column names                                    |
| WHERE    | See operators below                                              |
| ORDER BY | One or more columns, `ASC` / `DESC`                              |
| LIMIT    | Maximum number of rows; combined with **Max Rows** (lowest wins) |

**WHERE operators**

| Operator                        | Example                      |
| ------------------------------- | ---------------------------- |
| `=`, `<>`, `>`, `>=`, `<`, `<=` | `Amount >= 100`              |
| `LIKE`                          | `Customer LIKE 'A%'`         |
| `IN`, `NOT IN`                  | `Country IN ('FR', 'IE')`    |
| `IS NULL`, `IS NOT NULL`        | `ShippedDate IS NULL`        |
| `AND`, `OR`, parentheses        | `A = 1 AND (B = 2 OR C = 3)` |

**INSERT, UPDATE, DELETE**

```sql
INSERT INTO Orders (OrderId, Customer, Amount) VALUES (1001, 'Contoso', 250.00)
UPDATE Orders SET Status = 'Closed' WHERE OrderId = 1001
DELETE FROM Orders WHERE Status = 'Cancelled'
```

* UPDATE and DELETE without a WHERE clause affect every row of the sheet.
* Columns that do not exist in the sheet are ignored.
* Each write rewrites the whole worksheet: values and formulas are kept, cell formatting is not.

**Parameters**

Named parameters are supported in WHERE conditions and values:

```sql
SELECT * FROM Orders WHERE Customer = @customer AND Amount > @minAmount
```

**Not supported**

* `JOIN`, sub-queries and `UNION`
* `GROUP BY`, `HAVING` and aggregate functions (`COUNT`, `SUM`, …)
* Column aliases (`AS`) and expressions in the column list
* `CREATE` / `ALTER` / `DROP` — sheets and columns must already exist in the workbook
* Stored procedures and transactions


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/system-settings/data-sources/connection-settings/spreadsheets/excel.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
