For Each: Specified cast is not valid. While using For Each

Hii everyone
please help me why i am getting this type error how to resolve it


Hi @zaid.ahmad
Can you show us the activity and code which throw this error?

@zaid.ahmad , For what use are you using this loop?

To loop a datatable?? then you have to use “for each row in datatable” activity

@zaid.ahmad ,
Can you provide a screen shot of your activity and the property panel?


In the for loop properties you have to change the type argument according to the items you have in the in argument you provided.

Say you provided a list of strings then type argument will be string


Hello @sangeethaneelavannan1 @muhamed_fasil @Anil_G
Actually i was using excel application scope for reading multiple xml file one by one after that i want to read whole sheet of each file and using get workbook sheet activity and then using for each row for getting Sheet name and the data type i kept as a String.


Good…but,which for each did you use and what type of variable you passed in the in arguments


You should use for each activity not for each row

i have using For Each and type argument is String

Yes i am Using For Each activity


In the for each what did you give as in argument?

Type argument depends on the in argument you passed


Get workbook sheet return sheet name as string.inside for each,what Activity you used?

I have passed the String Argument

I have use same as a String


Why are you using loop if it is already a string?


@zaid.ahmad , The output of the get worksheet name should be list of string right?

Can you just confirm me on that? that list of string variable should be passed to " for each " with type argument as string!

Hi @zaid.ahmad the output of get workbook sheet is string but another activity get workbook sheets is there,that return list of string.which one you are using?

yes right i have passed in String

i am using List of String in get workbook sheet What should be use there?

@zaid.ahmad , can you provide the screen shot?