How to add 2 numbers from Web, adds both up and save to Excel

Hi everyone,

Just started with UiPath.

I scraped 2 texts, which are number from website, wish to add up both number and then save to Excel. Can help?


welcome to community

  1. Scrape Numbers:
  • Use the “Data Scraping” wizard to scrape numbers from the website.
  • Indicate the elements containing the numbers.
  • UiPath will generate a DataTable variable (scrapedDataTable) with the scraped data.
  1. Assign Activity - Calculate Sum:
  • Use an “Assign” activity to calculate the sum of the scraped numbers.
    Assign: totalSum = scrapedDataTable.AsEnumerable().Sum(Function(row) Convert.ToDouble(row(“ColumnName”)))

  • Open the “Assign” activity and create a new variable totalSum.

  1. Write to Excel:
  • Use the “Write Range” activity to write the total sum to an Excel file.
  • Specify the file path, sheet name, and range.

Hi @KimSanWu ,

If you already have scrapped text then you can try below command in assign activity

Output = (CInt(text1)+CInt(text2)).ToString

If you would like to write all three to excel then

  1. Build data table with three columns (value1,value2,output) and store it in dt_Output

  2. Use add data row activity, give datatable as dt_Output and in array row parameter pass {text1,text2,Output}

  3. Use write workbook range activity and write the datatable to excel - filepath, datatable and sheet name should be given as parameter

If you would like to write only the output to excel then

  1. Use write cell activity to write the output value - file name, cell value in which it should be written and the output value are the inputs

Thanks, will try it out!

1 Like

may be late but will try to help you anyway =)

after getting those strings from your website you can use an assign activity and convert those value to int/double with:
var1 = Convert.ToInt32(yourVariable)
var1 = Convert.ToDouble(yourVariable)
(depends on what kind of type your scraped text´s are)

next you can write the sum into excel by using “Write Cell” or “Append Range” inside an “Use Excel File” Activity.
you can either say var1 + var2 or assign/create a new variable like varSum, if you plan to use the sum elsewhere for example.

Thank for the suggestion!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.