How to trim excel file

Hi,

I’m reading one huge excel file (5000 records) using Excel application scope, I want to trim any whitesapces in the data to avoid datatype mismatch error. I searched a lot but couldn’t find any useful resources. Is there any way to trim the entire excel file while reading it??

Thanks in advance.

Trim as in you wan to remove the complete row which is blank?
or for some specific columns you want to see there is data or not.

Hi thanks for the reply

Some data are aligned like for ex: “John” and
" John" so I want to remove any extra sapces within the data

hey @MLT
if you’re sure that space will be at start you can remove them using .TrimStart if not then just use .Trim for that particular row.
suppose your column name is NAME which has john then in for each row use assign and then
row(“NAME”).ToString = row(“NAME”).ToString.Trim

this should work
if this solved your problem please mark it as solution

Cheers,
Parth