http://qs321.pair.com?node_id=313795


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 ;
 _  _ _  _  
(_|| | |(_|><
 _|