RPA.Excel.Files
create workbook
from RPA.Excel.Files import Files
excel = Files()
excel.create_workbook(path="output/output.xlsx",fmt="xlsx")
excel.save_workbook()
read_worksheet_as_table
When you load the excel data, run the task, then you will see the detail in the HTML log file.
from RPA.Excel.Files import Files
def fill_form_with_excel_data():
"""Read data from excel and fill in the sales form"""
excel = Files()
excel.open_workbook("SalesData.xlsx")
worksheet = excel.read_worksheet_as_table("data", header=True)
excel.close_workbook()
for row in worksheet:
fill_and_submit_sales_form(row)
# Receive a row, and read every cell with column header
def fill_and_submit_sales_form(sales_rep):
"""Fills in the sales data and click the 'Submit' button"""
page = browser.page()
page.fill("#firstname", sales_rep["First Name"])
page.fill("#lastname", sales_rep["Last Name"])
page.select_option("#salestarget", str(sales_rep["Sales Target"]))
page.fill("#salesresult", str(sales_rep["Sales"]))
page.click("text=Submit")