So… the core mission with this very simple program is to take the values from A1:A10 in a exceel and move them into the same cell range in another excell sheet. This part is okey and my program does that without problem. But, the values in the first excel doc contains decimals, such as 10.5. In the process when I move them between the excel files, how can I at the same time round up every numbers?
Can you tell me how are you moving the data ?
Welcome to uipath community
We can pass them as text like this
That is once after getting the first datatable named dt1 pass tat as input to FOR EACH ROW activity
Inside the loop use a assign activity like this
row(“yourcolumnname”) = “‘“ + row(“yourcolumnname”).ToString
That is we are concatenating the string value with single quotes in front
Next to this for each row loop we can pass that as input to another excel
Welcome to the Uipath Community!
If you wish to round the number you can use: Math.Round(yourVariable)
In my example below I have 1.1 and it rounded the value to 1
Hello rmunro and thank you very much for the reply! This is what I look for, however - I tried myself and I get a error message… I show you a screenshot now, but in my case I have a table, which i made from reading ca. 15 cells from excel: take a look here:
Dt1 is a variable of type datatable
And we won’t able to change it directly with Math function on it
Rather we can pass this expression inside a FOR EACH ROW LOOP
—pass the datatable Dt1 as input to For each row activity
And inside the loop use a assign activity like this
row(“yourcolumnname”) = Math.Round(Convert.ToDouble(row(“yourcolumnname”).ToString)).ToString
Then we can write back to the excel with a write range activity next to this for each row loop
The reason for suggesting dingle quote concatenation is if we have the rounded value already and if that has to be passed to another excel with same format then if we convert that particular column type to text then the same format will be retained
That’s why buddy
Hello, is it possible to show me how it looks like in a screenshot? I am very new and you seem to know what you talk about but I struggle with understand how and where to implement your suggested code!
Great! We are going the right path then. You have to loop through that column of the datatable. Like @Palaniyappan mentioned but instead of using row(“yourcolumnname”).ToString you will use Math.Round(Convert.ToInt32(row(“yourcolumnname”)))
Main.xaml (7.4 KB)
See my attached file of how I did it with a test excel file.
So here’s what I did.
Hello again! I tried a couple times now but… Im getting closer! Now I get an error because of what I write in the brackets “numbers”. What do you write here? I write the title of my column but … error message says “Termin_1” (which is what I wrote insted of “numbers”) is not a part of DataTable. Any idea my friend? I will give you nice review if it is possible. i am new on this site
Try with column index
That is we can mention columnindex instead of column name like this row(2) And usually column index starts from 0 for the first column in excel
Hey, I tried to remove “…” and just write 2 instead. Now error says “cant find row 2”. Any idea? You are all very kind…
If possible can I have a screenshot of how it was mentioned
As I can see we have read the data from excel with column A alone which is only one column-first column
So the index should be 0
Then mention as row(0) and try once
Kindly try this and let know pls
Hello my friend, I tried now: But I seem to get the original error mistake with the columnname… any idea?
Did we try with column index
Make sure that your column name is exactly the same name, no spaces or anything and also that you have the headers option selected so the read range is able to detect the headers.