Inserting another column of data into existing datatable

hi everyone,
I have an excel sheet contains company name with the help of company names i had extracted data from the web, with read range activity i am reading that company names, now i want to add the extracted rows into the same datatable
can anyone help me to solve this

@Manisha541

  1. Use Read Range activity to read the data from excel file and will give you output as DataTable and say ‘inputDT’.

  2. And then use ForEach Row activity to iterate that DataTable.

       ForEach row in inputDT
           int index = inputDT.Rows.IndexOf(row)+2
           Then use Write Cell activity to write into Excel and pass range as "C"+index.Tostring
    

Note: Here C refers to C column. You can change according to you in which cell you want to write.

1 Like

i want to insert div data into another column of the same data table

with assign activity how can i add the another column to the existing datatable?

@Manisha541
Adding a data column can be done with this activity:

Take care and dont use it within a Loop, do it instead before

ok but i scraped the data from web, that should be inserted into another column of the datatable
i already for read range used one datatable now the scraped data also want to be saved in that excel only

Maybe I didn’t get you

you have an existing DataTable
you do scraping from web
you want to write back to Excel datatable + extrainfo, right?

so one option could be:
create a second datatable from origin datatable: assign - dtExtended = dtOrigin
add this additional column to dtExtended (Activity named as above)
Fill up the added column with infofrom webscraping row by row
Use dtExtended within a write range and write it to Excel

actually i have company names in my excel using that company names i am scraping the data from web now i want to add these scraped data to the same excel sheet

to read that excel file with read range activity i have created a datatable dt now i want to add scraped data to that same datatable dt

Yes, is doable
once you have prepared the dtExtended by dtExtended = dtOrigin with additional column
then you can iterate and set row by row the retrieved information from web on the column eg
row(“myCompanyInfoColumn”) = myScrapedCompanyInfo

Feel free to post your xaml as well for getting additional help