How to get desired number of characters from excel to string. it should be dynamic.?

How to get only desired number of characters from excel to string. it should be dynamic.?

Hi
we can use substring method like htis
yourstringvariable.ToString.SubString(starting index of character, number of characters need)
where starting index sttarts from 0 for first character
for example
str_input = “abcdef”
str_input = str_input.ToString.SubString(0,3)
the output will be “abc”

Cheers @rahul_gola

1 Like

Hi thank you for your help palaniyappan,

but i am getting an error. ss attached

1 Like

fine may i know what is the actual length of that string
to find that
yourvariable.Length.ToString
kindly find that and mention the number of characters to retrieved

Cheers @rahul_gola

yes the length of the string is 26, but i want it to be dynamic
ex: in fist field it cannot be more then 128
in 2nd field it cannot be more then 20
but i want what so ever is there till 20 to be in the field.
and in 3rd it should not be more then 12.

i have tried the above but no luck

1 Like

can i have an example of input and how many characters you need from each column
Cheers @rahul_gola

i have attached an ss for you reference,
i want that text from excel to be filed into another column, there i have restriction in the first filed where the length limit is only 128,
in 2nd column i have a limit of 50 characters,
and in 3rd limit reduced to 12.

title

1 Like

ok got it
so the expression be like this in the type into activity

for first column
str_input.ToString.SubString(0,IF(str_input.ToString.Length<128,str_input.ToString.Length,128)

for second column
str_input.ToString.SubString(0,IF(str_input.ToString.Length<50,str_input.ToString.Length,50)

for third column
str_input.ToString.SubString(0,IF(str_input.ToString.Length<12,str_input.ToString.Length,12)

Cheers @rahul_gola

2 Likes

Thank you,

i am having an error ss attached.

1 Like

str_input.ToString.SubString(0,(if (str_input.Length<128,str_input.length,128)))

sorry buddy
that was a typo mistake
str_input.ToString.SubString(0,IF(str_input.ToString.Length<128,str_input.ToString.Length,128)

for second column
str_input.ToString.SubString(0,IF(str_input.ToString.Length<50,str_input.ToString.Length,50)

for third column
str_input.ToString.SubString(0,IF(str_input.ToString.Length<12,str_input.ToString.Length,12)

Cheers @rahul_gola

is this working
kindly let know for any queries or clarification
Cheers @rahul_gola

1 Like

Hi so sorry to reply late was busy in the further development. kinda urgent.

yes it is working great… thanks a lot for your help Palaniyappan :slight_smile:

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