Skip to content

Instantly share code, notes, and snippets.

@jeffa
Created August 29, 2013 14:23
Show Gist options
  • Save jeffa/6378762 to your computer and use it in GitHub Desktop.
Save jeffa/6378762 to your computer and use it in GitHub Desktop.
Transpose Excel docs from "portrait" to "landscape."
use strict;
use warnings;
use Math::Matrix qw(transpose);
use Spreadsheet::ParseExcel::Simple;
use Spreadsheet::WriteExcel::Simple;
my $xls = Spreadsheet::ParseExcel::Simple->read('old.xls');
my @data;
for ($xls->sheets) {
while ($_->has_data) {
push @data, [$_->next_row];
}
}
my $matrix = Math::Matrix->new(@data);
my $ss = Spreadsheet::WriteExcel::Simple->new;
$ss->write_row($_) for @{$matrix->transpose};
open OUT,'>','new.xls';
binmode OUT;
print OUT $ss->data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment