Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Transpose Excel Data

by gmax (Abbot)
on Dec 10, 2003 at 18:11 UTC ( #313795=note: print w/replies, xml ) Need Help??


in reply to Transpose Excel Data

A quicker alternative, which I found out by chance a few months ago.

Simpler without ::Simple. :-)

#!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel::Simple; use Spreadsheet::WriteExcel; # <--- my $xls = Spreadsheet::ParseExcel::Simple->read('old.xls'); my @data; for ($xls->sheets) { while ($_->has_data) { push @data, [$_->next_row]; } } my $ss1 = Spreadsheet::WriteExcel->new('new.xls'); my $ws = $ss1->add_worksheet('transposed'); $ws->write('A1', \@data); # Yes. IT IS transposed!

As a side note, in your example, instead of Math::Matrix you can use tye's Algorithm::Loops.

use Algorithm::Loops qw(MapCar); # .... $ss->write_row($_) for MapCar {[@_]} @data ;
 _  _ _  _  
(_|| | |(_|><
 _|   

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-12-05 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?