Hi Experts,
I have a case to read some cells from Excel that contain numerical data and I want robot to convert it to integer before calculation process. However, I got an error message as this:
I have tried both Convert.ToInt32() and .toInt32() function. Yet both not working as well.
Please advice. Thank you.
you can try this way
Convert.ToInt32(row("ColumnName").ToString)
or
CInt(CurrentRow("ColumnName").ToString)
@D_Okthree
As you are dealing with percentages
if it gets in decimal part then try
cdbl(row(“columnname”).tostring)
Hi @D_Okthree ,
Could you let us know what is the full Expression that you have used in the Assign
activity ?
@D_Okthree
use for each row in datatable or for each row in excel activity
Then assign
percentageresult=Cint(Currentrow(“columnName”).tostring)
if you want to convert to a integer
cheers
@Praveen_Mudhiraj ,
I got this issue now. The assigned variable has double data type.
I tried Convert.toInt32() and .stringValue() yet still get the same issue.
lrtetala
(Lakshman Reddy)
October 9, 2023, 11:17am
9
@D_Okthree
Try this
Cdbl(CurrentRow.ByField("TotalExpensevalue")*100)/finalTotalExpense
@lrtetala @Praveen_Mudhiraj ,
Why do I still get this error message whether I use Cint or Cdbl?
This is the formula
D_Okthree:
@D_Okthree ,
I believe it might be because you have not checked Has Headers
Option in the For Each Excel Row
activity.
@supermanPunch ,
I have and always. I did not change it since the table has header in Excel.
@D_Okthree ,
Is it possible for you to show us the Excel sheet representation ?
@supermanPunch ,
This is the expected result.
Now, in the For Each Row, I got this error message:
I used this inside the loop:
lrtetala
(Lakshman Reddy)
October 9, 2023, 11:50am
15
@D_Okthree
In Write Cell Where to Write give Excel.Sheet(“Sheet1”).Cell(“C3”)
Because the header is in Cell “C2”
Hi @D_Okthree ,
Hope you are doing good.
So you got the percentage value but unable to write or still in error.
Thanks,
Sandhiya P
D_Okthree:
@D_Okthree ,
We see that the Header starts from the Second row, Could it be changed in the Source file itself to remove the first blank row ?
Else, we would require to use the reference ByIndex
an then use an If activity with the Condition to Check if the value is Numeric like below :
@supermanPunch ,
I am not sure what is happening behind this but I changed the setting in the For Each Row and now there is no error.
Yet the result Excel still has header.
system
(system)
Closed
October 13, 2023, 4:48am
19
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.