Module - Workbook
Collection of functions related to MS Excel workbook. Use the Workbook activities to activate, close, open or close workbooks.
Activities
Open a workbook referenced by a workbook path. Once opened, use the Activate Workbook activity for further usage.
Technical Name |
Type |
Minimal Agent Version |
openExistingWorkbook |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Name |
Type |
Attributes |
Default |
Description |
workbookPath |
string |
mandatory
|
|
Full path of the existing workbook. |
openOptions |
irpa_excel.openOptionsDataType |
optional
|
|
Optional. Options to provide information when opening a workbook and to avoid some popups. |
Sample Code:
//Open a specific workbook irpa_excel.workbook.openExistingWorkbook('C:\\folder1\\folder2\\workbookName.xlsx', {updateLinks: 'updateLinks'});
Errors:
Error Class |
Package |
Description |
NotFound |
irpa_core |
Please check if the file is existing. Do you have the rights to access it. |
SequenceError |
irpa_core |
Please open Excel before to perform any activity. |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Close the active workbook.
Technical Name |
Type |
Minimal Agent Version |
close |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Name |
Type |
Attributes |
Default |
Description |
hasToSave |
boolean |
optional
|
false |
Set to true to save the workbook before closing it. Set to false for not saving it. |
Sample Code:
//Save and close the workbook const workbook = irpa_excel.workbook.close(true);
Sample Code:
//Close the workbook without to save it. const workbook = irpa_excel.workbook.close(false);
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Save the active workbook.
Technical Name |
Type |
Minimal Agent Version |
save |
synchronous
|
WIN-2.0.0
|
Sample Code:
//Save the active workbook irpa_excel.workbook.save();
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
"Save As" the active workbook.
Technical Name |
Type |
Minimal Agent Version |
saveAs |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Name |
Type |
Attributes |
Default |
Description |
filePath |
string |
mandatory
|
|
Full path corresponding to the new location of the workbook. |
fileFormat |
irpa_excel.enums.saveAsFormat |
optional
|
excelDefault |
Format to perform the "Save As" action. |
Sample Code:
//Save as the active workbook under a new file. irpa_excel.workbook.saveAs("C:\\myFolder\\fileName.xlsx");
Note:
The csv format might produce a loss of values and some features could not work as expected. Note that only the active worksheet is saved with this format.
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
InvalidArgument |
irpa_core |
Check the validity of the filePath parameter. |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Export the active workbook as a specified format like PDF or XPS.
Technical Name |
Type |
Minimal Agent Version |
exportAs |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Name |
Type |
Attributes |
Default |
Description |
filePath |
string |
mandatory
|
|
Full path corresponding to the location of the export. |
format |
irpa_excel.enums.exportAsFormat |
optional
|
pdf |
Format of the export. |
Sample Code:
//Export the active workbook as pdf. irpa_excel.workbook.exportAs("C:\\myFolder\\fileName.pdf");
Sample Code:
//Export the active workbook as xps. irpa_excel.workbook.exportAs("C:\\myFolder\\fileName.xps", irpa_excel.enums.exportAsFormat.xps);
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
InvalidArgument |
irpa_core |
Check the validity of the filePath parameter. |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Add a new workbook in the active application.
Technical Name |
Type |
Minimal Agent Version |
addNewWorkbook |
synchronous
|
WIN-2.0.0
|
Sample Code:
//Create a new active workbook. irpa_excel.workbook.addNewWorkbook();
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Please open Excel before to perform any activity. |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Activate a workbook that was opened previously. Once activated, additional operations might be possible (including worksheet operations).
Technical Name |
Type |
Minimal Agent Version |
activateWorkbook |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Name |
Type |
Attributes |
Default |
Description |
workbookName |
string |
mandatory
|
|
Name of the workbook to activate. |
Sample Code:
//Activate the workbook defined in input. irpa_excel.workbook.activateWorkbook("myWorkbookName.xlsx");
Errors:
Error Class |
Package |
Description |
InvalidArgument |
irpa_core |
The requested workbook does not exist |
SequenceError |
irpa_core |
Please open Excel before to perform any activity. |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Get the names of the worksheets in the workbook.
Technical Name |
Type |
Minimal Agent Version |
getWorksheetsName |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Output Parameters:
Name |
Type |
Description |
worksheetNames |
Array. |
Names of the worksheets in the workbook. |
Sample Code:
//Get the names of the visible worksheets in the workbook. const myWorksheetNames = irpa_excel.workbook.getWorksheetsName();
Sample Code:
//Get the names of the hidden worksheets in the workbook. const myWorksheetNames = irpa_excel.workbook.getWorksheetsName(irpa_excel.enums.visibilitySelection.onlyHiddenWorksheets);
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |
Get the names of the worksheets in the workbook.
Technical Name |
Type |
Minimal Agent Version |
getWorksheetsCount |
synchronous
|
WIN-2.0.0
|
Input Parameters:
Output Parameters:
Name |
Type |
Description |
worksheetsCount |
number |
Number of worksheets that the active workbook contains. |
Sample Code:
//Get the count of the visible worksheets in the workbook. const numberOfSheets = irpa_excel.workbook.getWorksheetsCount();
Sample Code:
//Get the count of hidden worksheets in the workbook. const numberOfSheets = irpa_excel.workbook.getWorksheetsCount(irpa_excel.enums.visibilitySelection.onlyHiddenWorksheets);
Errors:
Error Class |
Package |
Description |
SequenceError |
irpa_core |
Have you forgotten to open or create a workbook? |
EditModeError |
irpa_excel |
Excel is in edit mode and cannot be automated. Please leave the edit mode manually. |