Convert String To Int in DataTable


I got this scenario. I have a data table with some columns type is the string I want to convert this column to an integer to do some calculation.

some posting that I’m already tried but still no luck :

Attach the sample process (35.7 KB)



I would suggest to convert at the place where you want the value as int32
Just by mentioning as
Convert.ToInt32(your stringvariable) instead of mentioning directly your stringvariable

Cheers @rangga.waskita


Thanks for the quick feedback, do you mean I have to do for each in DT and convert the value to int32?


Yes. You will have to do it something like this.DtStringColumnToInt.xaml (8.2 KB)

Hi @Palaniyappan

is there any other way to convert the data not using that method. The thing is the real data will have a thousands of rows I wonder is there any simple way that not loop to every rows in the DT.


For some reason, I am unable to extract your attached file Are you able to attached a new one?

Hi ,

here’s the file

Thanks, (35.7 KB)

Hi @rangga.waskita

Please try below steps,

Read the excel sheet data or use build datatable and store the data in the datatable variable name dt.

Drag and drop the invoke code activity.

In edit arguments, create a variable dt, set direction as in/out and pass value as dt.

In edit code type the following,

dt.asenumerable.tolist.foreach(sub(row) row(“Yourcolumnname”)= cint(row(“Yourcolumnname”)))

Write the datatable back into the excel using write range activity.


We can use balareva activity to change the datatable column format, here is the reference for the same.

Hope this helps.



Hey, I think you’re solution is already correct. However, you missed the “add header” check box when reading the excel. Thus, you were actually reading Column H of the excel which are all zeros instead of Column G which has some non-zero values. I have attached the updated (10.5 KB)

Hi @prasath_S

It’s works, :love_you_gesture:


1 Like

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