SAP Help Home SAP Intelligent RPA Help Portal SAP Intelligent RPA Community

Module - Excel Online

Set of activities related to MS Excel Online. Use the Workbook activities to activate, close, open, or close a workbook.

Activities

Get Open Workbooks

Retrieve a list of all workbooks that are open.


Technical Name Type Minimal Agent Version
workbook.getOpenWorkbooks asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Output Parameters:

Name Type Description
openWorkbooksList Array.<irpa_365online.workbookInformation> The list of workbooks that are open.

Errors:

Error Class Package Description
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Open Workbook

Open a workbook if not already opened. Select the first worksheet of the workbook.


Technical Name Type Minimal Agent Version
workbook.openWorkbook asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
pathOrFileId string mandatory The path or the file ID of the workbook.

Output Parameters:

Name Type Description
workbookId string The workbook identifier.

Sample Code:

// file located on a remote drive designated by its id, accessed by the file id const wbid = await irpa_365online.excel.workbook.openWorkbook('myDriveId', 'myfileId');

Sample Code:

// file located on the local onedrive, accessed by the file id const wbid = await irpa_365online.excel.workbook.openWorkbook(undefined, 'myfileId');

Sample Code:

// file located on the local onedrive, accessed by the file path const wbid = await irpa_365online.excel.workbook.openWorkbook(undefined, 'test/myfile.xlsx');

Note:

To open workbook, the workbook must be shared in read write mode

Errors:

Error Class Package Description
RequestError irpa_core Error accessing the requested workbook.
NotFound irpa_core Ressource not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Open Workbook from Link Attachment

Open a workbook from a link attachment


Technical Name Type Minimal Agent Version
workbook.openWorkbookFromLinkAttachment asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
mailId string mandatory ID of the mail from which you want to use the link attachment
linkAttachmentName string mandatory The name of the link attachment

Output Parameters:

Name Type Description
workbookId string The workbook identifier

Sample Code:

// file located on a drive designated by its id, accessed by the file id const wbid = await irpa_365online.excel.workbook.openWorkbookFromLinkAttachment('dcpzcpzo', 'myWorkbook.xlsx');

Note:

To open workbook, the workbook must be shared in read write mode

Errors:

Error Class Package Description
RequestError irpa_core Error accessing the requested workbook.
NotFound irpa_core Ressource not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Select Current Workbook

Select a requested workbook among opened workbooks.


Technical Name Type Minimal Agent Version
workbook.selectCurrentWorkbook asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
workbookId string mandatory The workbook identifier.

Sample Code:

// Select the workbook which id is myGuid (output of openWorkbook) await irpa_365online.excel.workbook.selectCurrentWorkbook('myGuid');

Errors:

Error Class Package Description
SequenceError irpa_core This workbook is not open.
InvalidArgument irpa_core workbookId is malformed.


Close Workbook

Close a workbook.


Technical Name Type Minimal Agent Version
workbook.closeWorkbook asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
workbookId string mandatory The workbook identifier.

Sample Code:

// Close the workbook which id is myGuid (output of openWorkbook) await irpa_365online.excel.workbook.closeWorkbook('myDriveId', 'myfileId');

Errors:

Error Class Package Description
SequenceError irpa_core This workbook is not open.
RequestError irpa_core Error closing the workbook.
InvalidArgument irpa_core workbookId is malformed.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Get Values

Retrieve the values, formulas or numberFormats from the current worksheet.


Technical Name Type Minimal Agent Version
workbook.getRangeValues asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
rangeDefinition string mandatory The definition of the range.
format irpa_365online.enums.getFormat optional standard The format of the result.
cellProperty irpa_365online.enums.cellProperties optional values The cell property to return (values, formulas, numberFormats).

Output Parameters:

Name Type Description
result any The formatted result from the range.

Sample Code:

const values = await irpa_365online.excel.workbook.getRangeValues('A1:B2');

Sample Code:

// Get single value const values = await irpa_365online.excel.workbook.getRangeValues('A1');

Sample Code:

// Get row as a one dimension array const values = await irpa_365online.excel.workbook.getRangeValues('A1:C1', irpa_365online.enums.getFormat.reduceToList);

Sample Code:

// Get column as a one dimension array const values = await irpa_365online.excel.workbook.getRangeValues('A1:A10', irpa_365online.enums.getFormat.reduceToList);

Sample Code:

// Get values a objects which properties are describes in the first row of the range. const values = await irpa_365online.excel.workbook.getRangeValues('A1:B3', irpa_365online.enums.getFormat.objectsHeadersOnFirstRow);

Sample Code:

// Get formulas of the range. const formulas = await irpa_365online.excel.workbook.getRangeValues('A1:B3', undefined, irpa_365online.enums.cellProperties.formulas);

Errors:

Error Class Package Description
SequenceError irpa_core There is no current workbook.
RequestError irpa_core Error getting the values.
InvalidArgument irpa_core Error getting the values.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Set Values

Set values, formulas or numberFormats to the current worksheet.


Technical Name Type Minimal Agent Version
workbook.setRangeValues asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
rangeDefinition string mandatory The definition of the range.
values any mandatory Values of the range.
cellProperty irpa_365online.enums.cellProperties optional values The cell property to return (values, formulas, numberFormats).

Sample Code:

// Set values on a two dimensional range await irpa_365online.excel.workbook.setRangeValues('A1:B2', [['Hello', 'World'], [1, 2]]);

Sample Code:

// Set single value in a cell await irpa_365online.excel.workbook.setRangeValues('A1', 4);

Sample Code:

// Set values on a single row await irpa_365online.excel.workbook.setRangeValues('A1:C1', [['val1', 'val2', 'val3']]);

Sample Code:

// Set values on a single column await irpa_365online.excel.workbook.setRangeValues('A1:A3', [['val1'], ['val2'], ['val3']]);

Sample Code:

// Set the number format to change the display of numbers, dates, etc. await irpa_365online.excel.workbook.setRangeValues('A1:A3', [['hh::mm:ss'], ['d/m/yyyy'], ['0.00%']], irpa_365online.enums.cellProperties.numberFormat);

Errors:

Error Class Package Description
SequenceError irpa_core There is no current workbook.
RequestError irpa_core Error setting the values.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Get Worksheet List

Retrieve the list of worksheets in the current workbook.


Technical Name Type Minimal Agent Version
worksheet.getWorksheetList asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Output Parameters:

Name Type Description
worksheetList any The list of worksheets you want to retrieve.

Sample Code:

const wslist = await irpa_365online.excel.worksheet.getWorksheetList();

Errors:

Error Class Package Description
SequenceError irpa_core There is no current workbook.
RequestError irpa_core Error getting the worksheet list.


Select Current Worksheet

Select the current worksheet of the current workbook.


Technical Name Type Minimal Agent Version
worksheet.selectCurrentWorksheet asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
worksheetName string mandatory The name of the worksheet you want to select.

Sample Code:

await irpa_365online.excel.worksheet.selectCurrentWorksheet('myWorksheet');

Errors:

Error Class Package Description
SequenceError irpa_core There is no current workbook.
NotFound irpa_core This worksheet could not be found in the current workbook.
RequestError irpa_core Error getting the worksheet list.


Get UsedRange Row

Retrieve the row index of the used range in an active excel worksheet.


Technical Name Type Minimal Agent Version
worksheet.getUsedRangeRow synchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Output Parameters:

Name Type Description
usedRangeRow number Row index of the used range in the active worksheet.

Sample Code:

//get the row index of the used range in the active excel worksheet. const myRowIndex = irpa_365online.excel.worksheet.getUsedRangeRow();

Note:

The activity wil return 1 for an empty worksheet. Currently, for technical reason, this activity does not make the difference with a single value in A1.



Get UsedRange Column

Get the column index or name of the used range in the active excel worksheet.


Technical Name Type Minimal Agent Version
worksheet.getUsedRangeColumn synchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
columnInfoType irpa_365online.enums.columnInfoType optional index Column Info Type

Output Parameters:

Name Type Description
usedRangeColumn any Column index or name of the used range in the active worksheet.

Sample Code:

//get the column index of the used range in the active excel worksheet. const myColumnIndex = irpa_365online.excel.worksheet.getUsedRangeColumn();

Note:

The activity wil return 1 or 'A' for an empty worksheet. Currently, for technical reason, this activity does not make the difference with a single value in A1.



Create Worksheet

Create a MS Excel Online worksheet.


Technical Name Type Minimal Agent Version
worksheet.createWorksheet asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
name string mandatory Name of the worksheet.

Sample Code:

await irpa_365online.excel.worksheet.createWorksheet("New Worksheet");

Note:

The created worksheet is not automatically selected. To use it after its creation, please use the Select Worksheet activity after its creation.

Errors:

Error Class Package Description
RequestError irpa_core Error while creating a worksheet.
InvalidArgument irpa_core Invalid worksheet name.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.


Delete Worksheet

Delete a MS Excel Online worksheet.


Technical Name Type Minimal Agent Version
worksheet.deleteWorksheet asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
name string mandatory Name of the worksheet.

Sample Code:

await irpa_365online.excel.worksheet.deleteWorksheet('Worksheet to be deleted');

Errors:

Error Class Package Description
RequestError irpa_core Error while deleting the worksheet.
NotFound irpa_core This worksheet could not be found in the current workbook.
InvalidArgument irpa_core Invalid worksheet name.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.