Trying to insert an Integer Variable into Excel

Hello. I am trying to learn UiPath to create a bot to migrate our docs from a legacy system to a new system.

I have a big data table in Excel where each line is a doc, including their versions and revisions.

Both doc systems are web-browser based.

I created a new sheet (RPA) with a single line, where in a cell you change the number, and through an Excel Index function, I get all the info of that specific line into the new sheet.

Workflow of UiPath would be like this:

Create variable “counter” as integer and assign “0” to it.

Start Excel App Scope
At RPA sheet, B2, Writecell with variable “counter”
Read Cells D2, E2… Q2 to several different variables (which I will use later to type each variable in the webbrowser fields of the new system.

Ok, first of all…

-At RPA sheet, B2, Writecell with variable “counter”
That does not work, because variable counter is integer and Writecell only accepts strings.

So I tried, BEFORE opening Excel App Scope, to Assign Counter (integer) to CounterPaste (string). So at RPA sheet, B2, I would Writecell with variable “CoutnerPaste” (string)

But that ALSO did not work.

As I tried to assign an integer variable to a string variable, I get an error message "Cannot Assign from type System.Int32 to type System.String in Assign activity ‘Assign’.

It’s really confusing to me why you can´t write an integer variable into Excel… but ok, I may go around that restriction… however, please help me copying the content of an integer variable to a string one!

if you need to have a string use: convert.tostring(counter)

Conversion integer to string
IntegerVariable.ToString or Convert.ToString(Integer variable)
Conversion string to integer

if you need to have a string…

Hmmm, I am not sure I need to have a string. I guess so, otherwise I can´t write to Excel with WriteCell Activity (unless there is another way to do so?)

use: convert.tostring(counter)

thanks… but sorry to ask. Where do I use that? I searched and found no activities with the names “convert” or “counter”.

Take one assign activity.
In left side , you write your string variable .
In right side of assign activity , write - Counter.ToString

ok, ok, thanks. It was a bit difficult for me, not used to programming, to identify what were functions and what were variables in your posts. I understood now. Many thanks

You are always welcome to ask all kinds of doubts in forum here , please mark the answer as solved if it helped .
Feel free to ask your queries !!!

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