Excel to Web Data Transfer Using WinTask

Introduction

Welcome to this tutorial on using WinTask 7. In this session, we will demonstrate how to transfer data from an Excel file to web forms in a straightforward process that takes just about 5 minutes.

Preparing Your Data

You will start with an Excel file, which will have its data read and stored into arrays. Subsequently, we’ll use these arrays to populate a web form.

Setting Up

Before recording your script in WinTask, decide which browser you’ll use. Ensure you have the necessary browser extension installed for WinTask to function correctly. In this tutorial, we’ll proceed with Google Chrome.

Recording the Task

  • Visit the required web form address, which we’ll use for this demonstration.
  • Fill out the form fields with sample data of your choice.
  • Submit the form to complete the process.
  • Stop the recording.

Writing the Script

After recording, you may realize the need to close the browser at the end of the script. You can achieve this by adding the Close Browser function.

CloseBrowser()

Define arrays to represent each column in the Excel file. For instance, Dim area$(50) is used, but you can adjust the size based on your data.

Dim area$(50)
Dim firstname$(50)
Dim lastname$(50)
Dim email$(50)
Dim phone$(50)

excelfile$="C:/Users/Paul/Downloads/demo.xlsx"

The Read Excel function comes next. You’ll use the wizard to navigate through these steps:

  1. Enter the file path for your Excel file.
  2. Specify the cell range, like “A3:A27”, to store in an array named area$().
  3. Insert the function syntax into your code.
ReadExcel(excelfile$, "A3:A27", area$())
ReadExcel(excelfile$, "B3:B27", firstname$())
ReadExcel(excelfile$, "C3:C27", lastname$())
ReadExcel(excelfile$, "D3:D27", email$())
ReadExcel(excelfile$, "E3:E27", phone$())

Replace the static data captured during the recording with the dynamic data from your arrays.

Implementing the Loop

To automate the process for each row in your Excel file, implement a loop using a counter that increments after each form submission. Incorporate this counter into the Write HTML functions to ensure the correct data is inputted each time.

Utilize the repeat until construct to loop through the process until the last cell, determined by the array’s end, is empty.

StartBrowser("CH", "https://wintask.net/excel-to-web-form/",1)

i=0
repeat
UsePage("Excel to Web Form Tutorial - WinTask")
    SelectHTMLItem("SELECT[NAME='area']", area$(i))
    WriteHTML("INPUT TEXT[NAME='firstname']", firstname$(i))
    WriteHTML("INPUT TEXT[NAME='lastname']", lastname$(i))
    WriteHTML("INPUT TEXT[NAME='email']", email$(i))
    WriteHTML("INPUT TEXT[NAME='phone']", phone$(i))
    ClickHTMLElement("INPUT SUBMIT[VALUE='Submit']")
    i=i+1
until area$(i)=""

Running the Script

With everything set up, run your script. If written correctly, WinTask should automate the form filling using data from your Excel file seamlessly.

Conclusion

Thank you for following this tutorial. If you have any requests for future guides, please feel free to comment below.

Reference code:

Dim area$(50)
Dim firstname$(50)
Dim lastname$(50)
Dim email$(50)
Dim phone$(50)

excelfile$="C:/Users/Paul/Downloads/demo.xlsx"

ReadExcel(excelfile$, "A3:A27", area$())
ReadExcel(excelfile$, "B3:B27", firstname$())
ReadExcel(excelfile$, "C3:C27", lastname$())
ReadExcel(excelfile$, "D3:D27", email$())
ReadExcel(excelfile$, "E3:E27", phone$())

StartBrowser("CH", "https://wintask.net/excel-to-web-form/",1)

i=0
repeat
UsePage("Excel to Web Form Tutorial - WinTask")
SelectHTMLItem("SELECT[NAME='area']", area$(i))
WriteHTML("INPUT TEXT[NAME='firstname']", firstname$(i))
WriteHTML("INPUT TEXT[NAME='lastname']", lastname$(i))
WriteHTML("INPUT TEXT[NAME='email']", email$(i))
WriteHTML("INPUT TEXT[NAME='phone']", phone$(i))
ClickHTMLElement("INPUT SUBMIT[VALUE='Submit']")
i=i+1
until area$(i)=""

CloseBrowser()