---
schema_version: "1"
id: cef0ccc259a8cc0a0960f5983e07020e4543b20765e1c72aa0e6b69ba9363d71
title: Microsoft Excel Online Connector 1.1 Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/microsoft-excel-online-connector/latest/microsoft-excel-online-connector-examples.md
canonical_url: https://docs.mulesoft.com/microsoft-excel-online-connector/latest/microsoft-excel-online-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d362616980508cc8455633f8977d56209f01a375f399cac2f18455e5ba092eb1
description: MuleSoft Documentation Site
release: "1.1"
latest: true
---
---
product: Microsoft Excel Online Connector
version: 1.1
is-latest-version: true
---

# Microsoft Excel Online Connector 1.1 Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

This example shows you how to use Microsoft Excel Online Connector to perform the following actions:

- [Add a worksheet](#add-a-worksheet)

- [List a worksheet](#list-a-worksheet)

- [Update a worksheet](#update-a-worksheet)

- [Delete a worksheet](#delete-a-worksheet)

## Configure OAuth Authorization

Because this connector uses OAuth to secure connections, you must specify OAuth field values, such
as client credentials, keys, and OAuth-related URLs. To do this:

- Create a configuration file for the OAuth connection.

- Configure the OAuth-related global elements.

- Configure a global element for the properties file.

### Create a Configuration File for the OAuth Connection

Create a configuration file for the OAuth connection that includes properties for the
`Authorization Code` grant type:

1.  Create a file named `mule-app.properties` in the `/src/main/resources/` folder.

2.  In the `mule-app.properties` file, create a set of properties for the `Authorization Code` grant
    type, similar to the ones that follow, replacing the bracketed text (including the brackets)
    with the correct values for your OAuth configuration:

    config.oauth.authorization.code.consumerKey=<consumerKey>
    config.oauth.authorization.code.consumerSecret=<consumerSecret>
    config.oauth.authorization.code.authorizationUrl=<authorizationUrl>
    config.oauth.authorization.code.accessTokenUrl=<accessTokenUrl>

For more information about creating a properties file, see
[Configuring Property Placeholders](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-to-configure).

### Configure the OAuth Global Elements

Configure global elements for the `OAuth_Authorization_Code_Config` file:

1.  Create a new Mule project.

2.  In the **Mule Palette** view, click **Search in Exchange** and enter `microsoft excel`.

3.  Add **Microsoft Excel Online Connector** to the **Selected modules** section and click
    **Finish**.

4.  Click the **Global Elements** tab and click **Create**.

5.  Select **Connector Configuration > Microsoft Excel Online Authorization Code Config** and click
    **OK**.

6.  Enter the following values:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Name</p></td><td><p><code>OAuth_Authorization_Code_Config</code></p></td></tr><tr><td><p>Consumer key</p></td><td><p><code>${config.oauth.authorization.code.consumerKey}</code></p></td></tr><tr><td><p>Consumer secret</p></td><td><p><code>${config.oauth.authorization.code.consumerSecret}</code></p></td></tr><tr><td><p>Authorization url</p></td><td><p><code>${config.oauth.authorization.code.authorizationUrl}</code></p></td></tr><tr><td><p>Access token url</p></td><td><p><code>${config.oauth.authorization.code.accessTokenUrl}</code></p></td></tr><tr><td><p>Scopes</p></td><td><p>Leave the default: <code>https://graph.microsoft.com/.default</code></p></td></tr><tr><td><p>Listener config</p></td><td><p><code>auth</code></p></td></tr><tr><td><p>Callback path</p></td><td><p><code>/callback</code></p></td></tr><tr><td><p>Authorize path</p></td><td><p><code>authorizePath</code></p></td></tr><tr><td><p>External callback url</p></td><td><p><code>http://localhost:8083/callback</code></p></td></tr></tbody></table>

7.  Click **OK**.

### Configure a Global Element for the Properties File

Configure a global element for the `mule-app.properties` file so that Mule knows where to find it:

1.  Click the **Global Elements** tab and click **Create**.

2.  In the **Choose Global Type** dialog, select **Configuration properties** and click **OK**.

3.  In the **File** field, enter `mule.app.properties`.

4.  Click **OK**.

## Add a Worksheet

The following screenshot shows the Studio app flow for adding a new worksheet:

![Add Worksheet Studio flow](/mulesoft/current/en-us/microsoft-excel-online-connector/latest/_images/microsoft-excel-online-add-worksheet.png)

Figure 1. Use a flow like this one to add a new worksheet.

Adding a new worksheet involves configuring an HTTP **Listener** component, **Transform Message**
component, **Add worksheet** operation, and **Logger** component.

To create the flow:

1.  Create a new Mule project in Studio.

2.  In the **Mule Palette** view, search for **HTTP** and select the **Listener** operation.

3.  Drag the **Listener** operation onto the canvas.

4.  In the **Listener** configuration, click **+** next to the **Connector configuration** field to
    add a global element.

5.  Accept the defaults.

6.  In the HTTP properties window, set the **Path** field to `/create`.

### Add the Transform Message Component

The first **Transform Message** component creates a template for the input used to create the team:

1.  In the **Mule Palette** view, search for **transform message**.

2.  Drag the **Transform Message** component onto the canvas, to the right of the **Listener**
    component.

3.  In the **Transform Message** configuration, overlay the brackets in the **Output** section with
    this XML:

    ```xml
    <ee:set-payload ><![CDATA[%dw 2.0
    output application/json
    ---
    {
    	workbookId: attributes.queryParams.workbookID,
    	worsheetname: attributes.queryParams.worksheetName
    }]]></ee:set-payload>
    ```

### Add the Add Worksheet Operation

The **Add Worksheet** operation creates a new worksheet based on user input:

1.  Drag the **Add worksheet** operation onto the canvas, to the right of the **Transform Message**
    component.

2.  In the Add worksheet configuration, click the **Connector configuration** dropdown and select
    **Microsoft-Excel-Online-Authorization-Code-Config**.

3.  Select **Microsoft\_Excel\_Online\_Authorization\_Code\_Config** as the global element type and
    click **OK**.

4.  Configure the following fields in the Add worksheet properties window:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Workbook Id</p></td><td><p><code>payload.workbookId</code></p></td></tr><tr><td><p>Worksheet Name</p></td><td><p><code>payload.worsheetname</code></p></td></tr></tbody></table>

## List a Worksheet

Create a second flow to list a worksheet. Use the **List worksheet** operation in this flow:

![List Worksheet Studio flow](/mulesoft/current/en-us/microsoft-excel-online-connector/latest/_images/microsoft-excel-online-list-worksheet.png)

Figure 2. Use a flow like this one to list a worksheet.

## Update a Worksheet

Create a third flow to update information about a worksheet. Use the **Update worksheet** operation
in this flow:

![Update Worksheet Studio flow](/mulesoft/current/en-us/microsoft-excel-online-connector/latest/_images/microsoft-excel-online-update-worksheet.png)

Figure 3. Use a flow like this one to update information about a worksheet.

## Delete a Worksheet

Create a fourth flow to delete a worksheet. Use the **Delete worksheet** operation in this flow:

![Delete Worksheet Studio flow](/mulesoft/current/en-us/microsoft-excel-online-connector/latest/_images/microsoft-excel-online-delete-worksheet.png)

Figure 4. Use a flow like this one to delete a worksheet.

## Run the App

To run the app:

1.  Right-click the project in Package Explorer and select **Run As > Mule Application**.

2.  After the app deploys, open a web browser.

3.  Enter the following URL to start the OAuth dance: `http://localhost:8081/authorize`.

4.  In the login screen, enter the login information used to access Microsoft Excel Online and click
    **Login**.

5.  Click **Allow**.

6.  Initiate a flow by entering the associated URL, as shown in the following table:

    <table><colgroup><col> <col> <col></colgroup><thead><tr><th>Flow</th><th>URL</th><th>Notes</th></tr></thead><tbody><tr><td><p>Add a worksheet</p></td><td><p><code><a href="http://localhost:8081/create?workbookID={workbookID}&amp;worksheetName={worksheetName}">http://localhost:8081/create?workbookID={workbookID}&amp;worksheetName={worksheetName}</a></code></p></td><td></td></tr><tr><td><p>List a worksheet</p></td><td><p><code><a href="http://localhost:8081/list?workbookID={workbookID}">http://localhost:8081/list?workbookID={workbookID}</a></code></p></td><td></td></tr><tr><td><p>Update a worksheet</p></td><td><p><code><a href="http://localhost:8081/update?workbookID={workbookID}&amp;worksheetName={worksheetName}&amp;worksheetUpdateName={worksheetUpdateName}">http://localhost:8081/update?workbookID={workbookID}&amp;worksheetName={worksheetName}&amp;worksheetUpdateName={worksheetUpdateName}</a></code></p></td><td></td></tr><tr><td><p>Delete a worksheet</p></td><td><p><code><a href="http://localhost:8081/delete?workbookID={workbookID}&amp;worksheetName={worksheetName}">http://localhost:8081/delete?workbookID={workbookID}&amp;worksheetName={worksheetName}</a></code></p></td><td></td></tr></tbody></table>

## XML for the Examples

Paste this XML code into the **Configuration XML** tab in your project to experiment with the flows
described in the previous sections. When you paste this code, click **Yes** on the **Regenerate
'doc:id' Values** dialog.

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:excel="http://www.mulesoft.org/schema/mule/excel"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/excel http://www.mulesoft.org/schema/mule/excel/current/mule-excel.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="b67a7f0e-9d8f-43ee-b3d8-0a2f86fe10c5" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<excel:authorization-code-config name="Microsoft_Excel_Online_Authorization_Code_Config" doc:name="Microsoft Excel Online Authorization Code Config" doc:id="a03ea31c-ab5c-4508-ae87-91485d0d9201" >
		<excel:oauth-authorization-code-connection >
			<excel:oauth-authorization-code consumerKey="${consumerKey}" consumerSecret="${consumerSecret}" authorizationUrl="${authorizationUrl}" accessTokenUrl="${accessTokenUrl}" scopes="${scopes}" resourceOwnerId="${resourceOwnerId}"/>
			<excel:oauth-callback-config listenerConfig="HTTP_Listener_config" callbackPath="/callback" authorizePath="/authorize" externalCallbackUrl="http://localhost:8081/callback" />
		</excel:oauth-authorization-code-connection>
	</excel:authorization-code-config>
	<configuration-properties doc:name="Configuration properties" doc:id="2820ecc1-e8be-4b5f-8d6e-5eb3afaf1732" file="mule-app.properties" />
	<flow name="create-flow" doc:id="fcdaa88d-173a-4213-aaef-65bdcf384f03" >
		<http:listener doc:name="Listener" doc:id="f6a51e00-2be8-4524-9e39-cd4e3387b5e0" config-ref="HTTP_Listener_config" path="/create"/>
		<ee:transform doc:name="Transform Message" doc:id="f277839a-9e59-4d2a-9d53-c4d2f012ae90" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	workbookId: attributes.queryParams.workbookID,
	worsheetname: attributes.queryParams.worksheetName
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<excel:add-worksheet doc:name="Add worksheet" doc:id="071f5319-16ae-43dc-9420-bf47479eb3d1" config-ref="Microsoft_Excel_Online_Authorization_Code_Config" workbookId="#[payload.workbookId]" worksheetName="#[payload.worsheetname]"/>
		<logger level="INFO" doc:name="Logger" doc:id="9dd54e43-357e-454d-94ff-ccace4bcb580" message="Worksheet ID : #[payload.id]"/>
	</flow>
	<flow name="list-flow" doc:id="5b1b8836-f3a2-445e-b495-c80d93dcd82d" >
		<http:listener doc:name="Listener" doc:id="0ffa794c-37a4-4c57-a14d-da7009fa504f" config-ref="HTTP_Listener_config" path="/list" />
		<ee:transform doc:name="Transform Message" doc:id="f71f89a7-0f51-44ba-9e46-18e6f8dcc8c8" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	workbookId: attributes.queryParams.workbookID
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<excel:list-worksheet doc:name="List worksheet" doc:id="5e576012-f3a1-428a-b20f-d9d5a3442398" config-ref="Microsoft_Excel_Online_Authorization_Code_Config" workbookId="#[payload.workbookId]"/>
	</flow>
	<flow name="update-flow" doc:id="0cfe6bad-85e8-4e61-9688-52c6b37a93a8" >
		<http:listener doc:name="Listener" doc:id="6c874287-c011-4b19-b3e8-55744003f0f6" config-ref="HTTP_Listener_config" path="/update"/>
		<ee:transform doc:name="Transform Message" doc:id="d0697ad3-e842-48cd-b0c4-016dd65a712e" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
		name : attributes.queryParams.worksheetUpdateName
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<excel:update-worksheet doc:name="Update worksheet" doc:id="983a65bc-584b-4199-867d-abfb9cf09bcb" config-ref="Microsoft_Excel_Online_Authorization_Code_Config" workbookId="#[attributes.queryParams.workbookID]" worksheetId="#[attributes.queryParams.worksheetName]">
		</excel:update-worksheet>
	</flow>
	<flow name="delete-flow" doc:id="c989f49f-809c-4593-95dc-f93f8634c609" >
		<http:listener doc:name="Listener" doc:id="f6e8d004-e264-48c1-85cf-b2ce5a0135d6" config-ref="HTTP_Listener_config" path="/delete"/>
		<ee:transform doc:name="Transform Message" doc:id="ea4da82b-cd40-4bf6-b8c7-04efe280d835" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	workbookId: attributes.queryParams.workbookID,
	worksheetName: attributes.queryParams.worksheetName
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<excel:delete-worksheet doc:name="Delete worksheet" doc:id="183fb53f-0c3d-42c2-8676-df485f9a5f43" config-ref="Microsoft_Excel_Online_Authorization_Code_Config" workbookId="#[payload.workbookId]" worksheetId="#[payload.worksheetName]"/>
	</flow>
</mule>
```
