Downloading and reading an Excel file

This example demonstrates how to download and how to read data from an Excel file. We will use RPA.Excel.Files and RPA.HTTP libraries from the RPA Framework.

Robot Framework example

*** Settings ***
Documentation       Download an Excel file and read the rows.

Library             RPA.Excel.Files
Library             RPA.HTTP

*** Variables ***

*** Tasks ***
Download an Excel file and read the rows
    Download    ${EXCEL_FILE_URL}    overwrite=True
    Open Workbook    Data.xlsx
    ${table}=    Read Worksheet As Table    header=True
    Close Workbook

    FOR    ${row}    IN    @{table}
        Log    ${row}

Python example

from RPA.Excel.Files import Files
from RPA.HTTP import HTTP

excel_lib = Files()
http_lib = HTTP()

excel_file_url= ""

def download_the_excel_file(url):, overwrite=True)

def open_the_file_as_table():
    table = excel_lib.read_worksheet_as_table(header=True)
    return table

def loop_over_table(table):
    for row in table:

# Define a main() function that calls the other functions in order:
def main():
    table = open_the_file_as_table()

# Call the main() function, checking that we are running as a stand-alone script:
if __name__ == "__main__":

See RPA.Excel.Files keyword documentation to learn more about working with Excel files.

May 5, 2022