ExcelLibrary

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

Introduction

Library for working with Excel documents.

Dependencies

robot framework http://robotframework.org

Example

Settings Value
Library ExcelLibrary.py
Library Collections
Test Cases Action Argument Argument Argument
Simple
Create Excel Document doc_id=docname1
Write Cell row=1 column=1 value=text
Save filename=file.xlsx
Close Current Excel Document

Shortcuts

Close All Excel Documents · Close Current Excel Document · Create Excel Document · Get List Sheet Names · Get Sheet · Open Excel Document · Read Excel Cell · Read Excel Column · Read Excel Row · Save Excel Document · Switch Current Excel Document · Write Excel Cell · Write Excel Column · Write Excel Row · Write Excel Rows

Keywords

Keyword Arguments Documentation
Close All Excel Documents

Closes all opened documents.

Example:

${doc1}= Create Excel Document docname1
${doc2}= Create Excel Document docname2
Close All Excel Documents
Close Current Excel Document

Closes current document.

Returns:

Closed document identifier.

Example:

${doc1}= Create Excel Document docname1
${doc2}= Create Excel Document docname2
Close Current Excel Document
Create Excel Document doc_id

Creates new excel document.

Args:

doc_id: document identifier in the cache.

Returns:

Identifier of created document.

Example:

Create Excel Document doc_id=doc
Close All Excel Documents
Get List Sheet Names

Returns a list of sheet names in the current document.

Returns:

List of page names.

Example:

Create Excel Document doc_id=doc1
${sheets}= Get List Sheet Names
List Should Contain Value ${sheets} sheet1
Close All Excel Documents
Get Sheet sheet_name=None

Returns a page from the current document.

Args:

sheet_name: sheet name.

Returns:

Document's sheet.

Open Excel Document filename, doc_id

Opens xlsx document file.

Args:

filename: document name.

doc_id: the identifier for the document that will be opened.

Returns:

Document identifier from the cache.

Example:

Open Excel Document filename=file.xlsx doc_id=docid
Close All Excel Documents
Read Excel Cell row_num, col_num, sheet_name=None

Returns content of a cell.

Args:

row_num: row number, starts with 1.

col_num: column number, starts with 1.

sheet_name: sheet name, where placed cell, that need to be read.

Returns:

Content of the cell in the specified column and row.

Example:

Open Excel Document filename=file1.xlsx doc_id=doc1
${a1}= Read Excel Cell row_num=1 col_num=1
Should Be Equal As Strings ${a1} text
Close All Excel Documents
Read Excel Column col_num, row_offset=0, max_num=0, sheet_name=None

Returns content of a column from the current sheet of the document.

Args:

col_num: column number, starts with 1.

row_offset: indent.

max_num: maximum number of columns to read.

sheet_name: sheet name, where placed column, that need to be read.

Returns:

List, that stores the contents of a row.

Example:

${doc1}= Create Excel Document doc_id=docname1
${col_data}= Create List a1 a2 a3
Write Excel Column col_num=3 col_data=${col_data} sheet_name=${DEFAULT_SHEET_NAME}
${cd}= | Read Excel Column | col_num=3 | max_num=3 | sheet_name=${DEFAULT_SHEET_NAME}|
Lists Should Be Equal | ${col_data} | ${cd} |
Close All Excel Documents |
Read Excel Row row_num, col_offset=0, max_num=0, sheet_name=None

Returns content of a row from the current sheet of the document.

Args:

row_num: row number, starts with 1.

col_offset: indent.

max_num: maximum number of rows to read.

sheet_name: sheet name, where placed row, that need to be read.

Returns:

List, that stores the contents of a row.

Example:

${doc1}= Create Excel Document doc_id=docname1
${row_data}= Create List t1 t2 t3
Write Excel Row row_num=5 row_data=${row_data} sheet_name=${DEFAULT_SHEET_NAME}
${rd}= Read Excel Row row_num=5 max_num=3 sheet_name=${DEFAULT_SHEET_NAME}
Lists Should Be Equal ${row_data} ${rd}
Close All Excel Documents
Save Excel Document filename

Saves the current document to disk.

Args:

filename: file name to save.

Example:

Create Excel Document doc_id=doc1
Save Excel Document filename=file1.xlsx
Close All Excel Documents
Switch Current Excel Document doc_id

Switches current excel document.

Args:

doc_id: identifier of the document to switch.

Returns:

Identifier of previous document.

Example:

${doc1}= Create Excel Document docname1
${doc2}= Create Excel Document docname2
Switch Current Excel Document ${doc1}
Close All Excel Documents
Write Excel Cell row_num, col_num, value, sheet_name=None

Writes value to the cell.

Args:

row_num: row number, starts with 1.

col_num: column number, starts with 1.

value: value for writing to a cell.

sheet_name: sheet name for write.

Write Excel Column col_num, col_data, row_offset=0, sheet_name=None

Writes the data to a column.

Args:

col_num: column number, starts with 1.

col_data: list of values for writing.

row_offset: number of indent rows from start.

sheet_name: sheet name for write.

Write Excel Row row_num, row_data, col_offset=0, sheet_name=None

Writes a row to the document.

Args:

row_num: row number, starts with 1.

row_data: list of values for writing.

col_offset: number of indent columns from start.

sheet_name: sheet name for write.

Write Excel Rows rows_data, rows_offset=0, col_offset=0, sheet_name=None

Writes a list of rows to the document.

Args:

rows_data: list of rows for writing.

col_offset: number of indent columns from start.

rows_offset: number of indent rows from start.

sheet_name: sheet name for write.