How to take action base on whether the specific excel cell is null or not?

Dear Experts

I have a request as below, can you have give me some guidance about how to do it:

  • I need to fill in a website form base on the specific detail in a excel file one by one
  • If the specifi excel cell is null, then no need to input corresponding box in the website form
  • If the specifi excel cell is not null, then replace the original content in the website box with the excel cell detail

Example:

  • Excel column [Latest Financial Year Total Revenue] is null, then no need to change the website box content(which is “0” in below screenshot)
  • Excel column [Latest Finanacial Year Total Capital] is not null, then replace the original website box content(“8,000,000”) with the excel cell detail(“10,000,000”)

Thank you for your advise in advance

Ivan

@yangyq10

You can use read cell to read the data into a variable make sure you keep the variable datatype as GenericValue…

Then after read cell use if condition with IsNothing(variable) OrElse String.IsNullOrEmpty(variable.ToString) …on then side it is null so do nothing and on else side it is not so write the data to required field you need using ui activities like type into and pass variable.ToString as in put

Cheers

@Anil_G Thank you, can you help take a look if I am doing it right as below?



@yangyq10

Then condition looks correct …hope you selected or instead of and

But it would be better if you open advanced editor and write orelse instead of or…

Cheers

I just try to run it but there is some error on IF, can you help take a look?

image
image

@yangyq10

Did you use orelse only?

or did you use OR?

cheers

@Anil_G There are only 2 options in IF. I use Any(OR)

image

@yangyq10

as mentioned earlier…click on plus and open advanced editor and in place of or write orelse

cheers

@Anil_G Thank you for the reminder. It should be working now. Let me test another round on it

image

1 Like

@Anil_G

I am sorry that I have one more question for enhancement

Its possible that there is space in the blank filed. So I need to use [replace] to remove spaces

But it keep popping up error message

May I know how I should set it right?

image

image
image

image

Thanks

Hey @yangyq10 ,

You can check using

String.isnullorwhitespace(“yourstringvariable”)

Above will return true if it is empty space false if not

@yangyq10 try using .Trim instead of replace

Cheers

@Anil_G But Trim is only used for remove spaces at the beginning and end of a filed. Is it suitable in my scenario?

@yangyq10

So in the string where you have spaces you want to remove? or if only space is there you want to remove?

Also before replace try to check if the string is empty or not

cheers

@Anil_G There will be no string in such “empty fileds”. I just need to make sure there are no spaces in it while it looks like “empty”. Because it will recover the orignial data in the website form with spaces which will cause problems in business. All I need is to keep website form no change when the relative excel filed is completely null/empty(without spaces)

image

@yangyq10

then just use variablename.trim

cheers

@Anil_G

Below steps are what I revise just now, can you help take a look if any issue?

  1. If len>0, if yes, then assign A1 = A.trim
    image
    image
    image

  2. If A1 is empty or null. If no, then input information(A) in website

@yangyq10

instead of length >0 use Not IsNothing(Variable)

cheers

@Anil_G

I face a issue today when I further debug
There is actully some value in my excel column
However, after I ran below activities, the output message is True(which means the activities consider no vaule in my excel column)
Do you have any idea why this issue happen?

image

image

image

image

image

image

image

Thanks
Ivan

@yangyq10

Can you print the actual value and check if it is reqding as expected and also if it is reading yhe right cell

Cheers