I have to find particular string from my excel data table using If condition , any one help please
I have to find ‘No’ string in screenshot
Excel_Dt.AsEnumerable.Any(Function(r) r.ItemArray.Any(Function(o) o.ToString.Contains(“No”)))…this condition not working
Anil_G
(Anil Gorthi)
November 15, 2023, 1:14pm
2
@shaik.muktharvalli1
as No is in header…read the datatable with read range activity with header unchecked
alternately you can use find/replace activiity as well
cheers
@shaik.muktharvalli1
dt1.AsEnumerable.Any(Function(x) x.ItemArray.Any(Function(a) a.ToString.trim.Equals("No")))
if you want to use for each row in datatable activity
inside use if activity condition as
CurrentRow.ItemArray.any(Function(a) a.ToString.trim.Equals("No"))
@Shiva_Nikhil Conditions not worked
No is not a Header, Data extract from web and put in excel after we have to find No having or not
Anil_G
(Anil Gorthi)
November 15, 2023, 1:24pm
6
@shaik.muktharvalli1
What I mean was No is there in first row…so please check if the first row is considered as header then remove it and then search
dt1.AsEnumerable.Any(Function(x) x.ItemArray.Any(Function(a) a.ToString.ToLower.trim.Contains("no")))
cheers
1 Like
Excel_Dt.AsEnumerable.Any(Function(r) r.ItemArray.Any(Function(o) o.ToString.Trim.Contains(“No”)))
Using this condition but not worked
It’s going false condtion Anil
Anil_G
(Anil Gorthi)
November 15, 2023, 1:33pm
11
@shaik.muktharvalli1
can you print the datatable and highlight where no is present in it please
cheers
Anil_G
(Anil Gorthi)
November 15, 2023, 1:35pm
13
@shaik.muktharvalli1
that is what I a trying to explain…that no is in first row…please check if the first row is taken as header
can you please open locals panel when debugging and check the datatable there
cheers
can you send sample workflow for understand
Anil_G
(Anil Gorthi)
November 15, 2023, 1:40pm
15
@shaik.muktharvalli1
Okay do one thing after reading data to datatable
please use a log message and write this inside it String.Join(",",dt.Rows(0).ItemArray.ToArray)
show us the output of it
cheers
Anil_G
(Anil Gorthi)
November 15, 2023, 1:54pm
17
@shaik.muktharvalli1
that means the data thats is there in first row which contains a no is taken as column anme and not data
try this
dt1.AsEnumerable.Any(Function(x) x.ItemArray.Any(Function(a) a.ToString.ToLower.trim.Contains("no"))) OrElse (From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray().Any(Function(a) a.ToString.ToLower.trim.Contains("no"))
cheers
Thanks Anil Your patience, Finally Its worked
Thanks
Shaik
1 Like
Try to use: Excel_Dt.AsEnumerable.Any(Function(r) r.ItemArray.Any(Function(o) If(o.ToString.Contains(“No”), True, False)))
This command line ensures that the condition evaluates to either True or False.
If the issue still persist, attempt to check:
The data type compatibility by ensuring that the data type of the column you’re searching is compatible with the ToString
method. If the column contains non-string data, you might need to convert it appropriately.
Anil_G
(Anil Gorthi)
November 15, 2023, 3:03pm
20
@shaik.muktharvalli1
Awesome glad it helped…Can you please mark solution and close this
cheers