DoubleConverter cannot convert from (null)

I am having a problem with reading an cell from a excel, that would sometimes contains nothing or a value. Whenever I am reading this cell which is sometimes empty and assigning it to double. It outputs this error. Read Amount : DoubleConverter cannot convert from (null). I tried assigning it to String but it says StringConverter cannot convert from System.Double I hope you can help me with this. Thanks.

Hi,

Can you try to use GenericValue type variable at Result property, then convert it to your target type, as the following?

Regards,

Just have a default value for that variable

as the function eill surely fail if it’s having null as an argument.

Just in the variable panel, have a a default value.

1 Like

Use Double.TryParse and check

Dear Shinjid,

Please find the attached xaml and screenshot displaying the invoke method used to convert string ( empty/null/non empty value) to double using Double.TryParse.
Hope this helps.

If it solves your problem ,then please mark this as the solution so that it helps others facing the similar problems.

ForumDoubleExcel.xaml (7.5 KB)
EXCELDB.xlsx (13.7 KB)

Thanks,
Geetishree Rao

1 Like

Tried it and it works. Thanks.

Thanks, this worked too for me. Simple and easy.

Appreciate the solution.

Just wondering what can be the benefits for this long approach over providing a simple default value.

Would you not be able to use a simple IF-statement? If null, assign something else.

@rahulsharma , if you have default value, wouldn’t it overwrite it to the null if you do the assign?

These are various ways/alternatives(and need not worry whether input is null/not convertible), it depends on the individual and the requirement to decide which alternative to follow.
This method also handles if input(strings) cannot be converted to double,validation and exceptions handled.

No it won’t.

Logically when field is empty the robot get the text as null, that’s not a value to a variable, it doesn’t refer to any object.

And hence after extraction at conversion stage, the default value will be taken as the extracted one was null.

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