Adding variable information into specific Excel rows (per line)

Hello all,

Apologies for the noob question, I’m new!

As the title explains, I’d like to know how I can take captured variables and add them into an excel spreadsheet. I’ve used a scraper to successfully get the information I want from a website (which will run on several different pages) and capture specific parts and add them to a variable string.

Line by line, I want to paste this information into a row on a specific dedicated excel spreadsheet. So eg:

‘First name, middle name, last name, age’ all scraped from the site and pasted into row 2 on the spreadsheet (as 1 has headers - if the bot needs this specified, please let me know!'.
Then on the next scraped page, first name, middle name, last name, age again but this time onto row 3 as it’s different information, then row 4, 5 etc until there are no more pages to check.

How would I go about doing this?

Thanks for your help in advance.

This can be accomplished by placing all of this information inside of a datatable. Here are the steps

  1. At the beginning of your workflow use a place a build datatable activity. When creating it, add the number of columns your data will have and name them appropriately to what you want displayed inside your excel sheet later.

  2. Since you are already extracting the strings you can either use an assign statement e.g

    datatable.rows(count)("FirstName") = FirstName

    Or you can just extract it directly into the the data table and skip assigning the data to the string
    variable first (this would make your code a bit cleaner and easier to read). The above piece of
    code is assuming that you named the column for the “first name” variable “FirstName” and that
    you have a count variable for the loop when getting your data (make sure you initialize count to 0
    and increment this by one in the loop after you write your data to the table)

  3. After you have all the data stored inside of the data table you can directly use the excel activities. Use an “excel application scope” and place a “Write Range” activity inside and indicate the file you are writing and the datatable you will be writing to the spreadsheet. There is also an option in the write range to add headers, so make sure that is checked.

If you need any further assistance let me know!