ExcelRobot

Library version:1.0.0
Library scope:global
Named arguments:supported

Introduction

This test library provides some keywords to allow opening, reading, writing, and saving Excel files from Robot Framework.

Before running tests

Prior to running tests, ExcelRobot must first be imported into your Robot test suite.

Example:

Library ExcelRobot

To setup some Excel configurations related to date format and number format, use these arguments

Excel Date Time format

Date Format Default: yyyy-mm-dd
Time Format Default: HH:MM:SS AM/PM
Date Time Format Default: yyyy-mm-dd HH:MM

For more information, check this article https://support.office.com/en-us/article/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309

Excel Number format

Decimal Separator Default: .
Thousand Separator Default: ,
Precision Default: 2

Excel Boolean format

Boolean Format Default: Yes/No

Example:

Library | ExcelRobot | date_format='dd/mm/yyyy'

Importing

Arguments Documentation
date_format=yyyy-mm-dd, time_format=HH:MM:SS AM/PM, datetime_format=yyyy-mm-dd HH:MM, decimal_sep=., thousand_sep=,, precision=2, bool_format=Yes/No

Init Excel Keyword with some default configuration.

Excel Date Time format https://support.office.com/en-us/article/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309

Shortcuts

Check Cell Type · Create Sheet · Get Column Count · Get Column Values · Get Number Of Sheets · Get Row Count · Get Row Values · Get Sheet Names · Get Sheet Values · Get Workbook Values · Open Excel · Open Excel To Write · Read Cell Data · Read Cell Data By Name · Save Excel · Write To Cell · Write To Cell By Name

Keywords

Keyword Arguments Documentation
Check Cell Type sheet_name, column, row, data_type

Checks the type of value that is within the cell of the sheet name selected.

Arguments:

Sheet Name (string) The selected sheet that the cell type will be checked from.
Column (int) The column integer value that will be used to check the cell type.
Row (int) The row integer value that will be used to check the cell type.
Data Type (string) Available options: DATE, TIME, DATE_TIME, TEXT, NUMBER, BOOL, EMPTY, ERROR

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Check Cell Type TestSheet1 0 0 DATE
Create Sheet sheet_name

Creates and appends new Excel worksheet using the new sheet name to the current workbook.

Arguments:

New Sheet name (string) The name of the new sheet added to the workbook.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Create Sheet NewSheet
Get Column Count sheet_name

Returns the specific number of columns of the sheet name specified.

Arguments:

Sheet Name (string) The selected sheet that the column count will be returned from.

Example:

Keywords Parameters
Open Excel To Write C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Column Count TestSheet1
Get Column Values sheet_name, column, include_empty_cells=True

Returns the specific column values of the sheet name specified.

Arguments:

Sheet Name (string) The selected sheet that the column values will be returned from.
Column (int) The column integer value is indicated to get values.
Include Empty Cells (Default: True) If False then only return cells with values.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Column Values TestSheet1 0
Get Number Of Sheets

Returns the number of worksheets in the current workbook.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Number of Sheets
Get Row Count sheet_name

Returns the specific number of rows of the sheet name specified.

Arguments:

Sheet Name (string) The selected sheet that the row count will be returned from.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Row Count TestSheet1
Get Row Values sheet_name, row, include_empty_cells=True

Returns the specific row values of the sheet name specified.

Arguments:

Sheet Name (string) The selected sheet that the row values will be returned from.
Row (int) The row integer value value is indicated to get values.
Include Empty Cells (Default: True) If False then only return cells with values.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Row Values TestSheet1 0
Get Sheet Names

Returns the names of all the worksheets in the current workbook.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Sheets Names
Get Sheet Values sheet_name, include_empty_cells=True

Returns the values from the sheet name specified.

Arguments:

Sheet Name (string The selected sheet that the cell values will be returned from.
Include Empty Cells (Default: True) If False then only return cells with values.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Sheet Values TestSheet1
Get Workbook Values include_empty_cells=True

Returns the values from each sheet of the current workbook.

Arguments:

Include Empty Cells (Default: True) If False then only return cells with values.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Get Workbook Values
Open Excel file_path

Opens the Excel file to read from the path provided in the file path parameter.

Arguments:

File Path (string) The Excel file name or path will be opened. If file name then openning file in current directory.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Open Excel To Write file_path, new_path=None, override=False

Opens the Excel file to write from the path provided in the file name parameter. In case New Path is given, new file will be created based on content of current file.

Arguments:

File Path (string) The Excel file name or path will be opened. If file name then openning file in current directory.
New Path New path will be saved.
Override (Default: False) If True, new file will be overriden if it exists.

Example:

Keywords Parameters
Open Excel To Write C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Read Cell Data sheet_name, column, row, data_type=None, use_format=True

Uses the column and row to return the data from that cell.

  • Data Type indicates explicit data type to convert cell value to correct data type.
  • Use Format is False, then cell value will be raw data with correct data type.

Arguments:

Sheet Name (string) The selected sheet that the cell value will be returned from.
Column (int) The column integer value that the cell value will be returned from.
Row (int) The row integer value that the cell value will be returned from.
Data Type (string) Available options: TEXT, DATE, TIME, DATETIME, NUMBER, BOOL`
Use Format (boolean) (Default: True) Use format to convert data to string.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Read Cell Data TestSheet1 0 0
Read Cell Data By Name sheet_name, cell_name, data_type=None, use_format=True

Uses the cell name to return the data from that cell.

  • Data Type indicates explicit data type to convert cell value to correct data type.
  • Use Format is False, then cell value will be raw data with correct data type.

Arguments:

Sheet Name (string) The selected sheet that the cell value will be returned from.
Cell Name (string) The selected cell name that the value will be returned from.
Data Type (string) Available options: TEXT, DATE, TIME, DATETIME, NUMBER, BOOL`
Use Format (boolean) (Default: True) Use format to convert data to string.

Example:

Keywords Parameters
Open Excel C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Read Cell Data By Name TestSheet1 A2
Save Excel

Saves the Excel file that was opened to write before.

Example:

Keywords Parameters
Open Excel To Write C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Write To Cell TestSheet1 0 0 34
Save Excel
Write To Cell sheet_name, column, row, value, data_type=None

Write data to cell by using the given sheet name and the given cell that defines by column and row.

If Data Type is not provided, ExcelRobot will introspect data type from given value to define cell type

Arguments:

Sheet Name (string) The selected sheet that the cell will be modified from.
Column (int) The column integer value that will be used to modify the cell.
Row (int) The row integer value that will be used to modify the cell.
Value (string|number|datetime|boolean) Raw value or string value then using DataType to decide data type to write
Data Type (string) Available options: DATE, TIME, DATE_TIME, TEXT, NUMBER, BOOL

Example:

Keywords Parameters
Open Excel To Write C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Write To Cell TestSheet1 0 0 34
Write To Cell TestSheet1 1 1 2018-03-29 DATE
Write To Cell TestSheet1 2 2 YES BOOL
Write To Cell By Name sheet_name, cell_name, value, data_type=None

Write data to cell by using the given sheet name and the given cell that defines by name.

If Data Type is not provided, ExcelRobot will introspect data type from given value to define cell type

Arguments:

Sheet Name (string) The selected sheet that the cell will be modified from.
Cell Name (string) The selected cell name that the value will be returned from.
Value (string|number|datetime|boolean) Raw value or string value then using DataType to decide data type to write
Data Type (string) Available options: DATE, TIME, DATE_TIME, TEXT, NUMBER, BOOL

Example:

Keywords Parameters
Open Excel To Write C:\Python27\ExcelRobotTest\ExcelRobotTest.xls
Write To Cell By Name TestSheet1 A1 34
Write To Cell By Name TestSheet1 A2 2018-03-29 DATE
Write To Cell By Name TestSheet1 A3 YES BOOL