Cannot assign from type 'System.String' to type 'UiPath.Excel.ExcelValue' in Assign activity 'Assign'

When I tried to set variable(matchedRow) to an excel cell, error message pop-up.

“Cannot assign from type ‘System.String’ to type ‘UiPath.Excel.ExcelValue’ in Assign activity ‘Assign’.”

of course, “matchedRow” is a string type, you can see in the screenshot, even if I set value to “12”, error still exists.

more strangely, I duplicated this assign acitivity to another process, it worked.

If you ever met this issue, kindly help me here, many thanks.

Hi @elwin.kong ,

This behavior is caused by differences in project compatibility or Excel activity versions between the two workflows. One treats CurrentRow() strictly as ExcelValue, the other allows implicit conversion. Explicitly assigning New UiPath.Excel.ExcelValue(matchedRow) or using an Object/ExcelValue variable fixes it consistently across projects.

Hi @elwin.kong

This issue happens because you are using Modern Excel activities In For Each Excel Row (Modern),
CurrentRow(“VAT Price 6%”) is not a String.
Its data type is UiPath.Excel.ExcelValue.
So when you try to assign-

1 a String variable (matchedRow)
2 or even a hardcoded "12”
Try this

CurrentRow(“VAT Price 6%”)
Set the value ExcelValue.FromObject(matchedRow)
If you are assigning a number use this

ExcelValue.FromObject(12)

Hope it help
Thanks

Hi @Maheep_Tiwari

Thanks for your quick response.

I have already tried by AI suggestions, but didn’t work.

May I ask how to “using an Object/ExcelValue variable fixes it”?

ExcelValue is a class type and cannot be used as an expression
CurrentRow(“VAT Price 6%”)
ExcelValue.FromObject(matchedRow)
Hope it help

Hi @nishiijain2000

Thanks for your response.

I tried.

and I have tried to upgrade or down grade UiPath.Excel.Acirivites , not working.

@elwin.kong
ExcelValue.FromObject() is available only in full Modern Windows projects.In Windows-Legacy or mixed projects, it is not supported.
Instead of assign activity you can check with write cell activity
CurrentRow(“VAT Price 6%”)
Value - matchedRow

Hope it works

@elwin.kong

Instead of Assign activity, use Write Cell activity to write values back to the excel cell.

Hi, @nishiijain2000

Thanks for your help, This is working.

1 Like

Hi @ashokkarale

Thanks for your help, This is working.

1 Like

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