String manipulation is not working if I try to write into excel

I extracted Humidity of a place from web as 91% . I have used str_Humidity.Substring(0,str_Humidity.Length-1) to eliminate %. It worked but when I try to write it in excel it is storing as 9100% please help.

saved as below into the excel:
image

Hi @rajeshmushini312

How this write line printing the value can you show that?

Regards
Sudharsan

As long as your string is extracted as ‘91%’ you can simply do str_Humidity.Replace("%", "")
If that still outputs as shown in your picture, make sure the formatting on that cell is correct in the excel file.

I received this result using the above:
image

HI @rajeshmushini312

you can try this regular expression

System.Text.RegularExpressions.Regex.Match(strinput,“[0-9]+”).Value

it will match only numbers

@rajeshmushini312

you can try this way its working all

in the write cell you mention like this conditions

  1. str_Humidity.Replace(“%”,“”)

  2. System.Text.RegularExpressions.Regex.Match(str_Humidity,“[0-9]+”).Value

3.System.Text.RegularExpressions.Regex.Replace(str_Humidity,“%”,“”)

write cell condition like this

image

for reference you can see the output :-
image

Initially I tried this way as well, but still it prints the same way into the excel.
Later got to know that, that was an excel issue, I formatted the cell to text and it worked.

anyway Thank you very much !

1 Like

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