Skip to main content

A Robot Framework library for reading, writing, and manipulating Excel and CSV files

Project description

RFExcel

A Robot Framework library for reading, writing, and manipulating Excel and CSV files.

PyPI version Python License

Overview

RFExcel provides Robot Framework keywords for verifying and manipulating spreadsheet data in .xlsx, .xls, and .csv formats. It preserves native Python types (int, float, bool, datetime) rather than coercing everything to strings, making data assertions precise and reliable.

Features

  • Multi-format support.xlsx, .xls (read/write), and .csv
  • Dual-mode operation — Edit mode (full in-memory read/write) and Streaming mode (memory-efficient, read-only, forward-only)
  • Native type preservation — cell values returned as int, float, bool, datetime, or str
  • Flexible row filtering — search criteria with exact or partial matching, AND logic across multiple columns
  • Sheet management — switch, add, delete, and list sheets
  • Cell-level access — get and set individual cells by coordinate (e.g. A1, C3)
  • Lazy XLS conversion.xls write operations convert in-memory to .xlsx without modifying the original file
  • Comparison — diff two workbooks side-by-side with Compare Data To

Supported Formats

Format Edit mode Streaming mode Notes
.xlsx yes yes Full read/write via openpyxl
.xls yes* yes* *Write triggers lazy in-memory conversion to .xlsx; original file unchanged
.csv yes yes No sheet concept; sheet keywords raise OperationNotSupportedForFormat

Installation

pip install RFExcel

Dependencies: openpyxl>=3.0.0, robotframework>=7.0.0, xlrd>=2.0.2

Quick Start

*** Settings ***
Library    rfexcel.RFExcelLibrary

*** Test Cases ***
Read Rows From Excel
    Load Workbook    path=data.xlsx    read_only=True
    ${rows}=    Get Rows
    Length Should Be    ${rows}    4
    Should Be Equal    ${rows}[0][Product ID]    P-200

Filter Rows By Criteria
    Load Workbook    path=data.xlsx    read_only=True
    ${matching}=    Get Rows    search_criteria=Product ID=P-201;Price=89.99
    Length Should Be    ${matching}    1

Append And Save
    Load Workbook    path=data.xlsx
    ${row}=    Create Dictionary    Product ID=P-999    Description=New Item    Price=9.99
    Append Row    row_data=${row}
    Save Workbook    path=output.xlsx

Compare Two Files
    Load Workbook    path=baseline.xlsx
    ${differences}=    Compare Data To    target_path=updated.xlsx
    Should Be Empty    ${differences}

Keywords

Keyword Description
Load Workbook Open an existing file in edit or streaming mode
Create Workbook Create a new empty workbook
Save Workbook Persist changes to disk
Close Workbook Close the active workbook (done automatically at test end)
Switch Source Swap the active file without closing first
Get Rows Return all (or filtered) rows as a list of dicts
Get Row Return a single row by row number
Append Row Add a row at the end of the sheet
Append Rows Add multiple rows at once
Insert Row Insert a row at a specific position
Delete Row Delete a row by its row number
Delete Rows Delete all rows matching a search criterion
Update Values Update column values in all matching rows
Get Cell Get a single cell value by coordinate (e.g. A1)
Set Cell Set a single cell value by coordinate
Compare Data To Diff the active workbook against another file
Switch Sheet Set the active sheet by name
List Sheet Names Return all sheet names
Add Sheet Add a new sheet
Delete Sheet Remove a sheet by name

For the full keyword reference and argument details see the API documentation.

Search Criteria

Keywords that filter rows accept a search_criteria argument as either a dict or a semicolon-separated key=value string. Matching uses AND logic across all pairs.

# Dict syntax
${rows}=    Get Rows    search_criteria=${{ {"Product ID": "P-200", "Price": "25.5"} }}

# String syntax
${rows}=    Get Rows    search_criteria=Product ID=P-200;Price=25.5

# Partial matching
${rows}=    Get Rows    search_criteria=Description=Keyboard    partial_match=True

Data Types

Cell values are returned as native Python types:

Excel / CSV format Robot Framework type
Text / General str
Whole number int
Decimal / Currency float
Date / Time datetime
Boolean bool
Empty cell ""

Note: Because types are preserved, use type-aware assertions — e.g. Should Be Equal As Numbers for numeric cells rather than plain Should Be Equal.

Modes

Edit mode (read_only=False, default) — loads the full file into memory, supports reading and writing.

Streaming mode (read_only=True) — memory-efficient, read-only, strictly forward-only. Calling a read keyword twice on the same open workbook raises StreamingViolationException.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfexcel-0.9.0.tar.gz (40.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rfexcel-0.9.0-py3-none-any.whl (56.6 kB view details)

Uploaded Python 3

File details

Details for the file rfexcel-0.9.0.tar.gz.

File metadata

  • Download URL: rfexcel-0.9.0.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for rfexcel-0.9.0.tar.gz
Algorithm Hash digest
SHA256 a5cf0ee27ec5f45c235a86403323e728ae25f20da8d498d34173db4ade9e495a
MD5 0e943128dfc0645e1b88fe790dbe7c11
BLAKE2b-256 821511224ae08986f02f8b593c37b2271ac890716a274fe626788ddc67c7a285

See more details on using hashes here.

File details

Details for the file rfexcel-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: rfexcel-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 56.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for rfexcel-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 251bb10fa1d315e0235b827022f3a110a7087443aa26142b0e3f7907fb036264
MD5 049283e5ac7f37a47ac46bba15b8445f
BLAKE2b-256 42e81723d426079dcb95c46bf3dd95bd5846ac852af423f4a9c2e8e0ccd09c11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page