How to create array of strings for each row from Excel Data-table?

excel
activities

#1

Hi there,

I am trying to create array of strings for each row in excel data table. However, I could not find easy way to do it.

At the moment I am using “Get row item” for each column but I am receiving error if the value in the cell is not numeric.

Could you please help?

Best,


#2

Hello,

Could you guys take a look, please?

Thanks,

@Dominic
@aksh1yadav
@Susana


#3

@oduzen001 use for each row inside for each row use get row item


#4

Hi @oduzen001,

Multiple ways to do it. Before that read the excel and store into datatable variable dt

  1. Best Usage of activities - [No foreach required]
  • Use Output Datatable - Activity to get the entire datatable in a string variable (say strDatatable)
  • Split the string based on Environment.NewLine the output will be in String Array.
  1. Using LINQ - [No foreach required]
  • Use the below Linq query in Assign activity

     string() strArray = (From row in dt.Select()
                         Select String.Join(",",row.ItemArray)).ToArray()
    

Hope it was clear :slight_smile:


#5

I am going to try it as fast as I can and get back to you. Thank you so much!


#6

Hello Dominic,

I tried and it solved my problem. Thank you very much!! :slight_smile: