# Write Range

> `UiPath.MicrosoftOffice365.Activities.Excel.WriteRange`

`UiPath.MicrosoftOffice365.Activities.Excel.WriteRange`

## **Description**

Uses the Microsoft Graph [Update range](https://docs.microsoft.com/en-us/graph/api/range-update?view=graph-rest-1.0&tabs=http) API to write a range of cell data (**DataTable**) starting from a specific cell (**Starting Cell**) in a specified workbook (**Workbook**) worksheet (**SheetName**).

### Scopes

This activity requires the following scopes:

* Files.ReadWrite

OR

* Files.ReadWrite.All

OR

* Sites.ReadWrite.All

## Project compatibility

Windows - Legacy | Windows

## **Configuration**

**Properties**

#### Common

* **DisplayName** - The display name of the activity. This property supports `String` variables and string formatted values.

#### Input

* **DataTable** - The table to insert. This field supports only `DataTable` variables. To get the `DataTable` variable, create a table using the [Build Data Table](https://docs.uipath.com/activities/other/latest/user-guide/build-data-table) or [Generate Data Table](https://docs.uipath.com/activities/other/latest/user-guide/generate-data-table) activity and use its output property variable.
* **Sheet Name** - The name of the sheet to which data is written. This value must match the name of an existing worksheet, otherwise, an *ItemNotFound* error is thrown. This activity doesn't create a new sheet if it can't locate the name specified in this property. This property supports `String` variables and string formatted values.
* **StartingCell** - The address at which the top-left cell of the table is written. Enter the address of a single cell in A1-style notation.This property does not support a range of cells (e.g., *"A1:A5"*). This property supports `String` variables and string formatted values.
* **Workbook** - The `DriveItem` of the document to modify. This object can be retrieved using the [Find Files And Folders](https://docs.uipath.com/activities/other/latest/productivity/office365-find-files-and-folders) activity. Use the output property variable from either the **Find Files and Folders** (**First** or **Results**) or [Create Workbook](https://docs.uipath.com/activities/other/latest/productivity/office365-create-workbook) (**Workbook**) activities. When using the **Results** output property from the **Find Files and Folders** activity, be sure to specify which item in the array that you want to use (e.g., *myWorkbooks(0)*).

#### Misc

* **Private** - If selected, the values of variables and arguments are no longer logged at Verbose level. This field only supports Boolean values.

#### Options

* **IncludeHeaders** - If selected, the data table's headers are also inserted into the workbook. This field only supports Boolean values (True, False). The default value is **True**.

## How it works

The following steps and message sequence diagram is an example of how the activity works from design time (i.e., the activity dependencies and input/output properties) to run time.

1. Complete the steps.
2. Add the [Microsoft Office 365 Scope](https://docs.uipath.com/activities/other/latest/productivity/microsoft-office-365-scope) activity to your project.
3. Add an activity or run an external process that outputs a `DriveItem` object (e.g., [Find Files and Folders](https://docs.uipath.com/activities/other/latest/productivity/office365-find-files-and-folders), [Create Workbook](https://docs.uipath.com/activities/other/latest/productivity/office365-create-workbook), [Copy Item](https://docs.uipath.com/activities/other/latest/productivity/office365-copy-item)).
4. Add an activity that outputs a `DataTable` object (e.g., [Build Data Table](https://docs.uipath.com/activities/other/latest/user-guide/build-data-table), [Generate Data Table](https://docs.uipath.com/activities/other/latest/user-guide/generate-data-table)).
5. Add the **Write Range** activity inside the **Microsoft Office 365 Scope** activity.
6. Enter values for the Input properties.
7. Run the activity.
   * Your input property values are sent to the [UpdateRange](https://docs.microsoft.com/en-us/graph/api/range-update?view=graph-rest-1.0&tabs=http) API.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-181036-6836007b.webp)
