Hello all,
I am doing a quick test on an excel table, and during it, I found myself needing to treat the case of a specific cell being empty (which isn’t too hard, I could just use a cell = “” condition). So, for testing purposes, I am trying to see what value is typically returned for an empty cell by default. However, by trying to use a generic type variable to check that, as the datatable can have varying values for it’s cells, I have found myself unable to get the conversion right, as I can’t store the value of a cell (of type object) into a generic type variable, which makes sense.
I however would like to know if there is a way to convert an object into a generic value, as I didn’t find one after looking for it.
Thanks in advance,
Bastien
Don’t use Generic Value. It’s not a real datatype, it’s something made up by UiPath. It isn’t a datatype, it’s more a container that can hold any datatype - so you still won’t know what the datatype is of what’s in it.
Are you using Build Datatable before Read Range? You don’t have to do that. Just let Read Range create the datatable for you. Then it’ll handle the datatype for you.
Oh, okay, thanks. Also, no, I do use directly the DataTable that’s output by the Read Range activity.
Though, the thing is that I’m already using Generic Value for another process, for which I was making this test, so that’s why I wanted to use it…
Do you know what value an empty cell has then ? As in, in which case is it Nothing and in which is it Null ?
Right click the activity right after Read Range. Click Toggle Breakpoint to add a breakpoint. Now Debug your project and when it pauses at the breakpoint look in the locals panel at the datatable variable. You can look in there to see the datatype and what the values are.
Also, why are you using a variable to check it? You don’t have to do that. You can directly check the value from the datatable, you don’t have to first assign it to a variable.
Ahh, thanks, I didn’t think of doing that, thank you very much !
That is because I’m using that information several times throughout the process, and it can be empty or already filled with a number, so it’s quicker than going through CurrentRow(index) every time I interact with it.
It may be a little quicker to write, but later when someone is trying to figure out what populates that variable it could be difficult. Referencing CurrentRow everywhere you need the value (you don’t have to use index, you can use the column name) makes it obvious where the value is coming from. In the end it’s just personal preference.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.