How to convert a column from excel into string array

Hi, im trying into convert column into array of string can anyone help me in this
Thank you.

Check4.xaml (18.8 KB)

Hi @Lava_Salagala

  • Read Range (Read Excel data into dtReportOutput)

  • Assign (Convert “Employee Code” column to an array of strings)

employeeCodeArray= dtReportOutput.AsEnumerable().Select(Function(row) row.Field(Of String)("Employee Code")).ToArray()
  • Use employeeCodeArray as needed in your workflow.

Hope it helps!!

1 Like

Unable to cast object of type ‘System.Double’ to type ‘System.String’. im having this error when i debug how can i fix this can you explain in detail

Hi @Lava_Salagala

employeeCodeArray= dtReportOutput.AsEnumerable().Select(Function(row) row.Field(Of Double)("Employee Code")).ToArray()

Store this output in array of double.

Hope it helps

Hi,

you can use below expression in assign activity after read range(dtOutput)

EmployeeCodeArray = dtOutput.AsEnumerable().Select(Function(row) row(“Employee Code”).ToString()).ToArray()

This usually occurs when u reading column of different type and mentioning as string while enumerating it
So better don’t mention my type to read column instead u can convert that to string like this

arr_output = yourdatatablename.AsEnumerable().Select(Function(a) a(“yourcolumnname”).ToString).ToArray()

Me here arr_output is a variable of type array of string

Hope this helps

Cheers @Lava_Salagala