[28069] in Perl-Users-Digest
Perl-Users Digest, Issue: 9433 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 6 21:10:12 2006
Date: Thu, 6 Jul 2006 18:10:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Jul 2006 Volume: 10 Number: 9433
Today's topics:
Spreadsheet::[Parse|Write]Excel - accessing the content <justin.0607@purestblue.com>
Re: Spreadsheet::[Parse|Write]Excel - accessing the con <1usa@llenroc.ude.invalid>
Re: Spreadsheet::[Parse|Write]Excel - accessing the con <jgibson@mail.arc.nasa.gov>
Re: Sticky form <tadmc@augustmail.com>
Re: Sticky form krakle@visto.com
Re: Symbol Table and References anno4000@radom.zrz.tu-berlin.de
Win32::SerialPort dead in 5.8? aaron.propst@gmail.com
Re: Win32::SerialPort dead in 5.8? <sigzero@gmail.com>
Re: Win32::SerialPort dead in 5.8? <aaron.propst@gmail.com>
Re: Win32::SerialPort dead in 5.8? <trwww@sbcglobal.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 Jul 2006 20:51:44 -0000
From: Justin C <justin.0607@purestblue.com>
Subject: Spreadsheet::[Parse|Write]Excel - accessing the contents of a cell
Message-Id: <slrneaqtt1.3cm.justin.0607@moonlight.purestblue.com>
I've been trying to follow the examples given in the
Spreadsheet::ParseExcel module and appear to have become stuck. I have a
spreadsheet, most of which I need to copy to a new spreadsheet...
A6 to J6084 (well, that last number changes each time the sheet is
updated but I can extract that info from the sheet).
What I have so far is:
---- START ----
use strict ;
use warnings ;
use Spreadsheet::ParseExcel ;
use Spreadsheet::WriteExcel ;
my $orig_file = "/home/data/common/alan/excel/CATALOGU/A_TO_Z.XLS" ;
my $new_file = "/var/www/download/files/complete_listing.xls" ;
my $newbook = Spreadsheet::WriteExcel->new($new_file) ;
my $newsheet = $newbook->add_worksheet() ;
my $oldbook = new Spreadsheet::ParseExcel::Workbook->Parse($orig_file) ;
my $oldsheet = $oldbook->Worksheet('Sheet1') ;
my $lastrow = $oldsheet->{MaxRow} ;
print $lastrow, "\n" ;
my $srow = 6 ; #start row - after all the header/front page stuff.
my $lcoumn = 9 ;#last col. - leave off the supplier detail.
my $r = $srow ;
while ( $r <= $lastrow ) {
my $c = 0 ;
while ( $c < 10 ) {
my $nsr = $r - $srow ; # new sheet row number
my $cell = $oldsheet->{Cells}[$r][$c] ;
$newsheet->write($nsr , $c , $cell->Value) if ( $cell->Value ) ;
$newsheet->write($nsr , $c , $cell->Format) if ( $cell->Format ) ;
printf "Row: %d Col: %d Nsr: %d\n", $r, $c, $nsr ;
$c++ ;
}
$r++ ;
}
---- END ----
The new xls file gets created, but it's empty. The while loops iterate
over the rows and columns in the original OK - well, according to the
second print statement above it's all incrementing properly.
If anyone can tell me why either the cell value and formatting aren't
being read, or they aren't being written, I'll be very grateful.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Thu, 06 Jul 2006 22:47:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Spreadsheet::[Parse|Write]Excel - accessing the contents of a cell
Message-Id: <Xns97F8BF2F61DC4asu1cornelledu@127.0.0.1>
Justin C <justin.0607@purestblue.com> wrote in
news:slrneaqtt1.3cm.justin.0607@moonlight.purestblue.com:
> The new xls file gets created, but it's empty.
What happens if you add an explicit:
$newbook->close;
at the end of the program?
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 06 Jul 2006 18:00:21 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Spreadsheet::[Parse|Write]Excel - accessing the contents of a cell
Message-Id: <060720061800216702%jgibson@mail.arc.nasa.gov>
In article <slrneaqtt1.3cm.justin.0607@moonlight.purestblue.com>,
Justin C <justin.0607@purestblue.com> wrote:
> I've been trying to follow the examples given in the
> Spreadsheet::ParseExcel module and appear to have become stuck. I have a
> spreadsheet, most of which I need to copy to a new spreadsheet...
> A6 to J6084 (well, that last number changes each time the sheet is
> updated but I can extract that info from the sheet).
>
> What I have so far is:
>
> ---- START ----
[start of program snipped]
> while ( $r <= $lastrow ) {
> my $c = 0 ;
> while ( $c < 10 ) {
Perl has 'for' loops, you know.
> my $nsr = $r - $srow ; # new sheet row number
> my $cell = $oldsheet->{Cells}[$r][$c] ;
> $newsheet->write($nsr , $c , $cell->Value) if ( $cell->Value ) ;
I would delete the if part of this statement. You don't know if
> $newsheet->write($nsr , $c , $cell->Format) if ( $cell->Format ) ;
This line is not correct. The format instance should be the fourth
(optional) argument of write. You are probably wiping out the value you
just stored. You apparently cannot just copy the format object from one
spreadsheet to another. You may have to set each format specifier
individually using the $format->set_... methods.
> printf "Row: %d Col: %d Nsr: %d\n", $r, $c, $nsr ;
> $c++ ;
> }
> $r++ ;
> }
>
> ---- END ----
>
> The new xls file gets created, but it's empty. The while loops iterate
> over the rows and columns in the original OK - well, according to the
> second print statement above it's all incrementing properly.
>
> If anyone can tell me why either the cell value and formatting aren't
> being read, or they aren't being written, I'll be very grateful.
Here is a program that copies a spreasheet and sets the color of the
copied cells. Maybe you can start with this. It uses the Cell() method
instead of Cells() (might be more efficient) and the add_format()
method of the Workbook. I leave the offset methods of moving cells to
you:
#!/usr/local/bin/perl
#
use strict;
use warnings;
use Spreadsheet::ParseExcel ;
use Spreadsheet::WriteExcel ;
print "Parse: $Spreadsheet::ParseExcel::VERSION\n";
print "Write: $Spreadsheet::WriteExcel::VERSION\n";
my $orig_file = "old.xls" ;
my $new_file = "new.xls" ;
my $newbook = Spreadsheet::WriteExcel->new($new_file) ;
my $newsheet = $newbook->add_worksheet() ;
my $oldbook = new Spreadsheet::ParseExcel::Workbook->Parse($orig_file) ;
my $oldsheet = $oldbook->Worksheet('Sheet1') ;
my $lastrow = $oldsheet->{MaxRow};
my $lastcol = $oldsheet->{MaxCol};
for( my $r = 0; $r <= $lastrow; $r++ ) {
for( my $c = 0; $c <= $lastcol; $c++ ) {
my $cell = $oldsheet->Cell($r,$c);
my $val = $cell->Value();
my $fmt = $cell->{Format};
my $font = $fmt->{Font};
my $newfmt = $newbook->add_format();
$newfmt->set_color( ( 'red', 'green', 'blue' )[($r+$c)%3] );
$newsheet->write($r, $c, $val, $newfmt );
}
}
Make sure you have the latest versions from CPAN:
Parse: 0.2603
Write: 2.17
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 6 Jul 2006 14:35:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Sticky form
Message-Id: <slrneaqpg7.hdv.tadmc@magna.augustmail.com>
Franzl Wisseworst <franzl.wisseworst@mailinator.net> wrote:
> Has anyone seen some free
> script anywhere which does something like it?
We discuss _programming_ in Perl here.
If you decide to write something in Perl to do that, then this
is the place to post.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Jul 2006 17:10:48 -0700
From: krakle@visto.com
Subject: Re: Sticky form
Message-Id: <1152231048.138773.296910@k73g2000cwa.googlegroups.com>
Tad McClellan wrote:
> Franzl Wisseworst <franzl.wisseworst@mailinator.net> wrote:
>
> > Has anyone seen some free
> > script anywhere which does something like it?
>
>
> We discuss _programming_ in Perl here.
>
> If you decide to write something in Perl to do that, then this
> is the place to post.
What tad meant to say was in CGI.pm there is a sticky widget...
------------------------------
Date: 6 Jul 2006 19:33:16 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Symbol Table and References
Message-Id: <4h56rsF1q3q0vU1@news.dfncis.de>
Ferry Bolhar <bol@adv.magwien.gv.at> wrote in comp.lang.perl.misc:
> Daniel:
>
> > Hello,
> > I am trying to understand symbol tables and references. Maybe someone
> > can give me a hint.
[Excellent summary of stashes and typeglobs snipped]
That much research ought to be conserved somewhere better than in a
random Usenet posting. If you were to rewrite it as a tutorial in
pod format, I bet p5p would take it aboard as perlglobtut or something.
Anno
------------------------------
Date: 6 Jul 2006 11:19:01 -0700
From: aaron.propst@gmail.com
Subject: Win32::SerialPort dead in 5.8?
Message-Id: <1152209941.759203.236550@s53g2000cws.googlegroups.com>
I need to talk to a serial port on my windows system to control a
microcontroller. I assumed win32::serialport would be available and
easily installed, but ppm doesn't know it exists. I tried manually
downloading it and installing it from a ppd file, and i get "Error: no
suitable installation target found for package Win32-SerialPort."
Then I found this:
http://ppm.activestate.com/BuildStatus/5.8-W.html
It looks like that module doesn't run under 5.8.. is that true? Does
anyone else have a way for me to interface with a serial device under
windows? Do i need to downgrade perl to 5.6 or something? (i'd hate
to have to do that.)
Thanks, sorry if this is a noob question.
Aaron
------------------------------
Date: 6 Jul 2006 11:56:59 -0700
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: Win32::SerialPort dead in 5.8?
Message-Id: <1152212219.201067.38390@k73g2000cwa.googlegroups.com>
aaron.propst@gmail.com wrote:
> I need to talk to a serial port on my windows system to control a
> microcontroller. I assumed win32::serialport would be available and
> easily installed, but ppm doesn't know it exists. I tried manually
> downloading it and installing it from a ppd file, and i get "Error: no
> suitable installation target found for package Win32-SerialPort."
>
> Then I found this:
> http://ppm.activestate.com/BuildStatus/5.8-W.html
>
> It looks like that module doesn't run under 5.8.. is that true? Does
> anyone else have a way for me to interface with a serial device under
> windows? Do i need to downgrade perl to 5.6 or something? (i'd hate
> to have to do that.)
>
> Thanks, sorry if this is a noob question.
>
> Aaron
You could see if Randy Kobes can get it to his PPM site for you?
Robert
------------------------------
Date: 6 Jul 2006 12:17:19 -0700
From: "snarkyFish" <aaron.propst@gmail.com>
Subject: Re: Win32::SerialPort dead in 5.8?
Message-Id: <1152213439.272158.139000@75g2000cwc.googlegroups.com>
Robert Hicks wrote:
> aaron.propst@gmail.com wrote:
> > I need to talk to a serial port on my windows system to control a
> > microcontroller. I assumed win32::serialport would be available and
> > easily installed, but ppm doesn't know it exists. I tried manually
> > downloading it and installing it from a ppd file, and i get "Error: no
> > suitable installation target found for package Win32-SerialPort."
> >
> > Then I found this:
> > http://ppm.activestate.com/BuildStatus/5.8-W.html
> >
> > It looks like that module doesn't run under 5.8.. is that true? Does
> > anyone else have a way for me to interface with a serial device under
> > windows? Do i need to downgrade perl to 5.6 or something? (i'd hate
> > to have to do that.)
> >
> > Thanks, sorry if this is a noob question.
> >
> > Aaron
>
> You could see if Randy Kobes can get it to his PPM site for you?
>
> Robert
cool! that put me on the right track..
I successfully installed it from:
http://www.bribes.org/perl/ppm/
now, to find out if there's a reason activestate doesn't list it..
*crossing fingers*
------------------------------
Date: Thu, 06 Jul 2006 20:23:58 GMT
From: "Todd W" <trwww@sbcglobal.net>
Subject: Re: Win32::SerialPort dead in 5.8?
Message-Id: <yjerg.60484$Lm5.10459@newssvr12.news.prodigy.com>
"snarkyFish" <aaron.propst@gmail.com> wrote in message
news:1152213439.272158.139000@75g2000cwc.googlegroups.com...
>
> Robert Hicks wrote:
>> aaron.propst@gmail.com wrote:
>> > I need to talk to a serial port on my windows system to control a
>> > microcontroller. I assumed win32::serialport would be available and
>> > easily installed, but ppm doesn't know it exists. I tried manually
>> > downloading it and installing it from a ppd file, and i get "Error: no
>> > suitable installation target found for package Win32-SerialPort."
>> >
>> > Then I found this:
>> > http://ppm.activestate.com/BuildStatus/5.8-W.html
>> >
>> > It looks like that module doesn't run under 5.8.. is that true? Does
>> > anyone else have a way for me to interface with a serial device under
>> > windows? Do i need to downgrade perl to 5.6 or something? (i'd hate
>> > to have to do that.)
>> >
>>
>> You could see if Randy Kobes can get it to his PPM site for you?
>>
>
> cool! that put me on the right track..
> I successfully installed it from:
> http://www.bribes.org/perl/ppm/
>
> now, to find out if there's a reason activestate doesn't list it..
> *crossing fingers*
>
I'm posting without double checking, but I believe ActiveState will not
provide a module from CPAN that does not pass its automated build system.
So, some people distribute modules that don't pass ActiveState's build, and
ActiveState automatically refuses to distribute it.
Randy Kobes repository dosen't have this policy, so you can get modules from
there that you can't get from ActiveState.
If you're worried, you can always download the module from CPAN and run the
tests... just make sure the versions match to the one you installed through
CPAN.
Also, 'perl -MCPAN -e shell' on ActiveSate perl works fine for modules that
don't have a component that requires compliation (but you'll need to put
nmake in your path). And if you have MVC++ installed and properly
configured, you can aways use CPAN.
Todd W.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9433
***************************************