Using two lists to merge both in one datatable

Hi Folks,

Topic 1:
I have two Lists (listActual, listBudget) both storing decimal format numbers (like 3343.00, 0.00, -513.21). What is the data type i should use to store these kinds of values, the values in both these collections is coming from Get Text Activity (textActual, textBudget) so it’s in String Format.

Topic 2:
Another question is, how do I use these two lists (listActual, listBudget) as my end goal is to put them in an Excel against the desired columns (Actuals & Budget) respectively.

we recommend List(Of Double) and convert the strings into a double e.g.
CDbl(“123.45”), DoubleParse, Convert.ToDouble methods

prepare a datatable with e.g. Build DataTable - dtResult
then populate the different list values at column / row with the help of e.g. Add Data Row
write it to excel e.g. Write range activity

Hi @ppr ,

Thanks for your reply :slight_smile:

Could you please provide a step by step detailed explanation for this :slight_smile:

Hi @shikharno.7

  1. It’s simply based on your requirement, you can store whatever datatype you want. If you want the values in the list as string then you can directly add them to List variable.

  2. Excel Application Scope (Provide Excel file path)
    Build DataTable
    For Each item in List
    Add Data Row (item) to DataTable
    Write Range

Hi @supriya117 , thanks for your response :slight_smile:

Could you please provide the step wise explanation using the variables mentioned above. I 'm getting stuck at Add Data Row.

For generals refer to the UiPath Academy

Init a list:
myDoubleList = new List(Of Double)

Converting a String to double:
myDouble = CDbl(myStringVar) | myStringVar has value: “123.45”


Lets Assume ListA = {123.45,45,12.89}, ListB = {17.35,12.48,7.15}

grafik
grafik
grafik

We recommend to enhance your requirements e.g. handling 2 lists with different length case check etc

1 Like

Thanks for the solution @ppr , it worked :slight_smile:

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