Validation of data in excel


My workflow includes to read value from excel and populating them onto a webpage.
but before going to webpage i want to check my excel file if it has the value for all the mandatory field.
Here i will be checking if excel have values for mandatory fields and if it does not throwing the exception and terminating the flow while if the value for optional fields are empty then it must continue the normal execution.

how can i achieve this?


1 Like

if u want to check that if the excel is having values then use if condition and write the condition as DT.Rows.Count>0 then process or else Exception

1 Like


You can read the excel which will give u output in form of data table.
Now you can imply rules for the mandatory fields, using data table operations.


1 Like

HI @Aishwarya_Thakur

You can check whether the excel sheet contains values in different ways.

  • Check whether excel sheet contains data

    • Read Range to read into datatable
    • Use DT.Rows.Count to get the number of rows available. This should be greater than zero
  • Check whether your mandatory cells have the data

    • Use a For Each Row loop
    • Use If activity to check whether it has data
      • Use For Each Row loop and within it do the following in an IF condition
      • String.IsNullOrEmpty(row("ColumnName').ToString) - Will return whether the cell is null or empty
1 Like

i used the same approach using dictionaries. i convert excel into dictionary, now i just need to check if there is any value present for each required corresponding key.

but i am facing problem with IF condition here, the expression i am using in IF is

item.Key.Equals(“keyText1”) And item.Value.Equals(IsNothing) Or item.Key.Equals(“keyText2”) And item.Value.Equals(IsNothing) Or item.Key.Equals(“keyText1”) And item.Value.Equals(IsNothing)

i have mentioned all the keys which needs to have some value and if value for the any key is null then excel validation error will be thrown.

Can u please tell me what am i writing wrong in IF condition

Hi @Aishwarya_Thakur

Here, the way you have written the condition is wrong. IsNothing is not checked like that. I have a workflow similar to what you are doing which I’m using for something else. This is how I’m doing it…

Not String.IsNullOrEmpty will return true if the string is not null or empty. Else it will return false which means the string is either null or empty.


thank you @Lahiru.Fernando: that woeked for me

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.