Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to remove white space from cells - Spreadsheet::ParseExcel
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Anupam Varma  
View profile  
 More options Sep 6 2012, 10:09 am
From: Anupam Varma <anupamove...@gmail.com>
Date: Thu, 6 Sep 2012 10:09:24 -0400
Local: Thurs, Sep 6 2012 10:09 am
Subject: Re: [Spreadsheet::ParseExcel] How to remove white space from cells - Spreadsheet::ParseExcel

I haven't worked on this for some time but I have these in my old script.
Hope it works.

my StringVal = $worksheet->get_cell($row, $col));
StringVal = trim (StringVal);

Copy the below sub at the end of your script.
sub trim{
 my $string = shift;
 $string =~ s/^\s+//;
 $string =~ s/\s+$//;
 return $string;

}

On Thu, Sep 6, 2012 at 9:43 AM, Tanscia <rbmwebmast...@googlemail.com>wrote:
> Hi,

> Thank you for your response.

> I may not have been entirely clear I *do* need to remove the new line
> character from the end of the string sitting in *$key[$row]*.

> White space within the string or at the beginning if the string is not an
> issue.

> On Wednesday, 5 September 2012 16:33:24 UTC+1, Anupam wrote:

>>  For white spaces you need to trim the value. Chomp will remove new line
>> character from the end of the string.
>>  On Sep 5, 2012 6:50 AM, "Tanscia" <rbmweb...@googlemail.com> wrote:

>>> Hi,

>>> I'd really appreciate some help.

>>> I am using Spreadsheet::ParseExcel to search an excel spreadsheet for a
>>> specific entry (specified by the user).

>>> I've created a hash with the data collected from the excel spreadsheet
>>> the key of which (an array) I use it to compare with the users entry and
>>> hey presto deliver the info required.

>>> The problem I have is that the excel spreadsheet has white space mainly
>>> carriage returns which I need to chomp but I've tried several ways of doing
>>> this and none of them work!

>>> Here's the part of the code which I'm trying to chomp

>>>                 if ($col == 0 || $col == 4 || $col == 9) {

>>>                     #Collect hash key and assign to @key array
>>>                     if ($col == 0) {
>>>                         *$key[$row] *= $worksheet->get_cell($row, $col);
>>>                     }

>>> I've tried

>>>                         chomp ($key[$row] = $worksheet->get_cell($row,
>>> $col));
>>>                         chomp ($key[$row] = $key[$row]->{_Value});
>>>                         chomp (@key);
>>>                         chomp $key[$row]->{_Value};
>>>                         chomp ($key[$row]);

>>> I can't understand why I can *print $key[$row]->{_Value};* but *chomp
>>> $key[$row]->{_Value};* is ineffective.

>>> I've basically tried every combination of chomp I can think of but the
>>> white spaces are still there!!!!

>>> Thanks in advance for looking into this one.

>>> Tanscia.

>>> --
>>> --
>>> You received this message because you are subscribed to the
>>> Spreadsheet::ParseExcel Google Group.

>>> For posting and other options visit this group at:
>>> http://groups.google.com/**group/spreadsheet-parseexcel?**hl=en<http://groups.google.com/group/spreadsheet-parseexcel?hl=en>

>>> You can also post by sending an email to:
>>> http://groups.google.com/**group/spreadsheet-parseexcel?**hl=en<http://groups.google.com/group/spreadsheet-parseexcel?hl=en>

>>  --
> --
> You received this message because you are subscribed to the
> Spreadsheet::ParseExcel Google Group.

> For posting and other options visit this group at:
> http://groups.google.com/group/spreadsheet-parseexcel?hl=en

> You can also post by sending an email to:
> http://groups.google.com/group/spreadsheet-parseexcel?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.