Hi Ken,
On Thu, 24 May 2012 08:41:36 -0700 (PDT)
Ken Furff <[email protected]> wrote:
> I am using the spreadsheet::xlsx module in a script im writing. I need to
> extract about 4 columns out of about 60. I need those specific columns for
> comparison and updating. I assume that I'll load the data into an array or an
> array of arrays for comparison. I am able to extract the contents of the
> file, but I cant figure out how to specify just those columns... I'll put the
> code i currently have below
>
> use Spreadsheet::XLSX;
>
> $excel = Spreadsheet::XLSX -> new ('build.xlsx');
> foreach my $sheet (@{$excel -> {Worksheet}}) {
>
> printf("Sheet: %s\n", $sheet->{Name});
> $sheet -> {MaxRow} ||=$sheet -> {MinRow};
>
> foreach $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
>
> $sheet -> {MaxCol} ||= $sheet -> {MinCol};
>
> foreach $col ($sheet -> {MinCol} .. $sheet -> {MaxCol}) {
>
> $cell = $sheet -> {Cells} [$row] [$col];
>
Here you can filter or extract the relevant items out of
@{ $sheet->{Cells}[$row] }.
You can do something like:
my @indexes = (2 .. (2+4-1));
my @desired_cells = @{ $sheet->{Cells}[$row] }[ @indexes ];
For more information, see:
http://perl-begin.org/topics/references/
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html
The KGB used to torture their victims by having them look at scrolling XSLT
code.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/