The excel contains only data and has no columnName
How to know if specific data is present in ColumnA
Hi @shilpashree.mohanty ,
You can iterate through datatable and use below expression to extract data from column A
CurrentRow.Item(0).ToString
there can be many rows for that column
Try to use this Linq
yourDT.AsEnumerable().Any(Function(x) x(0).ToString.Equals(“YourValue”))
If any value matches it will return True.
Use Read Range activity to read the excel data. Make sure you are unchecking Add headers property
. This will return you datatable with default column names like Column1, Column2...
Then use If
activity to check if your desired value is there in first column or not. Use this as a condition:
dt_Input.AsEnumerable().Any(Function(rw) rw("Column1").ToString = "Value you are checking for")
Step1 - Read the table using read range activity and ensure that “AddHeaders” property is unchecked
Step2 - Create a Boolean variable for example, bool_dataFound
Step3 - Use assign activity for the boolean variable:
bool_dataFound = DT.AsEnumerable.Any(Function(r) r(0).ToString.Equals(“value”))
If your desired value (“value”) is found, it will return bool_dataFound as True else False.
this is throwing error,
the datatable looks as below in watch panel,
[09-22-2024
09-23-2024
]
What error you are getting
dt_Schedule.AsEnumerable.Any(Function(r) r(0).ToString.Contains(todaysRunDate))
This is saying contains is not a member
Equals gives value as false
byt value is datatable is [09-23-2024]
Try this
dt_Schedule.AsEnumerable.Any(Function(r) CDate(r(0).ToString) = DateTime.Today)
convert the run date to string as todaysRunDate.ToString and try
that variable is already a string
can you share the excel file?
my dt_schedule is,
the below query gives false value,
dt_Schedule.AsEnumerable.Any(Function(r) r(0).ToString.Equals(System.DateTime.Now.AddDays(-1).ToString(“MM-dd-yyyy”)))
System.DateTime.Now.AddDays(-1).ToString(“MM-dd-yyyy”)) = 09-23-2024
Never compare dates in the form of string. If available in string then always convert to DateTime datatype and then do the comparison.
there is 1 excel file
bot will create a schedule tab and write todays date-1 to it and later delete that
so ideally there is no sheet
whats the query for my below activity then?
dt_Schedule.AsEnumerable.Any(Function(r) r(0).ToString.Equals(System.DateTime.Now.AddDays(-1).ToString(“MM-dd-yyyy”)))
If your system time is in same format as you are trying to compare use this.
dt_Schedule.AsEnumerable.Any(Function(r) CDate(r(0).ToString).Date =DateTime.Now.AddDays(-1).Date)
the format in system is different, it is / separated
Use this one
dt_Schedule.AsEnumerable.Any(Function(r) DateTime.ParseExact(r(0).ToString, "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture).Date =DateTime.Now.AddDays(-1).Date)