# Write Range

> `UiPath.MicrosoftOffice365.Activities.Excel.WriteRangeConnections`

`UiPath.MicrosoftOffice365.Activities.Excel.WriteRangeConnections`

## Description

Writes a DataTable variable to a specified Excel workbook cell range.

### Scopes

This activity requires the following scopes:

* Files.ReadWrite

OR

* Files.ReadWrite.All

OR

* Sites.ReadWrite.All

## Project compatibility

Windows | Cross-platform

## Configuration

* **Microsoft OneDrive & SharePoint connection** - The connection for the Microsoft 365 account to use in the activity.
* **Workbook** - The Excel workbook to use. The method to specify the folder to be retrieved: **Folder Picker**, **Enter Id**, **Enter Url**.
  + **Workbook sample** - The workbook template to use. The field is visible after clicking **Use workbook template**. Browse the OneDrive folders and select a workbook. In Studio Desktop, the option is available from the See more ![](https://dev-assets.cms.uipath.com/assets/images/activities/activities-image-365280-3bd6c9a1.webp) button menu next to **Range type**. To learn more, see [Working with templates](https://docs.uipath.com/activities/other/latest/productivity/working-with-templates).
  + **File/Folder picker** option: Select the Folder ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-368186-8e468e7b.svg) icon to browse the OneDrive or SharePoint files/folders and select a spreadsheet. This option accepts input as `IResource`.

    - Use the See more ![](https://dev-assets.cms.uipath.com/assets/images/activities/activities-image-365280-3bd6c9a1.webp) button menu to use a variable or select the **Reload Folder Data** option if you've modified your folders and need to retrieve the latest data.
  + **Enter Id** option:
    - **Workbook Id** - The ID of the workbook of interest. This field supports `String` type input.
    - **SharePoint site address** - The URL of the SharePoint site that contains the file or folder. This field supports `String` type input.Open your SharePoint site in a browser and copy its URL, e.g., `https://yourcompany.sharepoint.com/sites/ProductOfficial`.
    - **SharePoint document library** - The document library within the indicated SharePoint site that contains the file or folder. This field supports `String` type input. Open the **Documents** tab in your SharePoint site and copy the URL, e.g., `https://yourcompany.sharepoint.com/sites/ProductOfficial/Shared%20Documents/Forms/AllItems.aspx`.
  + **Enter Url** option:
    - **Workbook Url** - The URL of the workbook of interest. This field supports `String` type input. Retrieve the URL by opening the file in a browser.
* **Range** - The range to write in. This field is prepopulated with information retrieved from the selected spreadsheet or spreadsheet sample. This property supports `String` variables and string formatted values.
  + Select the **Update Ranges** option if you've modified your sheets and need to retrieve the latest data.
* **Include headers** - This property supports Boolean values. Set to **True** to also include the DataTable headers into the workbook.
* **How to write** - Specifies how to add the data to the specified range. The available options are:
  + **Overwrite** - Overwrite any previous data that exists.
  + **Append** - Write the data in the first empty row found.
  + **Append Right** - Write the data in the first empty column found. See the **Appending** section below for more information.
  + **Insert** - Insert a row.
* **Row position** - The row index position where the activity is to insert the row. The index can be used from iterating on the range rows using Read Range or For Each Row. This field is displayed if you select **How to write – Insert**. This field supports `Int32` type input.
* **What to write** - The data in the DataTable to be written in the workbook. This field supports `DataTable` variables. For example, you can use the output variable of a [Read range](https://docs.uipath.com/activities/other/latest/productivity/office365-excel-read-range-connections) activity.

:::note
Some special character combinations in the **Sheet**/**Range** name property can cause the activity to throw an error. For example, `Sheet%Test` is a valid input, but `Sheet%44` isn’t (`%44` is transformed into `D`).
:::

#### Appending

Appending data does not currently support named ranges.

| Range Type | Append (to the bottom) | Append Right |
| --- | --- | --- |
| Plain range (A1 notation) | Write the range to the first empty row found in the targeted range.It creates the number of rows necessary and fills in the range with the input range.If there isn't an empty row in the range, append the range to the bottom by inserting the necessary number of rows and adding the input range. | Write the range to the first empty column found in the targeted range.It creates the number of columns necessary and fills in the range with the input range.If there isn't an empty column in the range, append the range to the right by inserting the necessary number of columns and adding the input range. |
| Named range | Write the range to the first empty row found in the targeted range.It creates the number of rows necessary and fills in the range with the input range.If there isn't an empty row in the range, append the range to the bottom by inserting the necessary number of rows and adding the input range. | Write the range to the first empty row found in the targeted range.It creates the number of rows necessary and fills in the range with the input range.If there isn't an empty row in the range, append the range to the bottom by inserting the necessary number of rows and adding the input range. |
| Sheets | Write the range to the first empty row found in the targeted sheet.It creates the number of rows necessary and fills in the range with the input range.If there isn't an empty row in the range, append the range to the bottom by inserting the necessary number of rows and adding the input range. | Write the range to the first empty column found in the targeted sheet.It creates the number of columns necessary and fills in the range with the input range.If there isn't an empty column in the range, append the range to the right by inserting the necessary number of columns and adding the input range. |

**Known limitations for requests**

Be aware of request/response limits when working with ranges. The limit stands at 4 MB, e.g., on average 10,000 cells with 20 characters each for Read requests, 4,000 cells with 20 characters each for Write requests. For more information, see [Excel specifications and limits](https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3).

## Known limitation

An error occurs if you use **Write Row**/**Write Range** with the **Append** option and the destination range is a sheet that contains an empty table at the beginning (with no other data). The activity tries to insert a row in the sheet, at the start of the table, but Graph API returns an error.

## Example

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-279260-6720aa74.gif)

For more details, also check the following resources::

* [Excel Online activities](https://docs.uipath.com/activities/other/latest/productivity/excel-online-activities)
* [Create Workbook](https://docs.uipath.com/activities/other/latest/productivity/office365-excel-create-workbook-connections)
* [Delete Sheet](https://docs.uipath.com/activities/other/latest/productivity/office365-excel-delete-sheet-connections)
* [Read Cell](https://docs.uipath.com/activities/other/latest/productivity/office365-excel-read-cell-connections)
