#!perl -l015 use strict; use Spreadsheet::WriteExcel; my $arr = [ [ "a11", "12", "a13" ], [ "a21", "22", "a23" ], [ "a31", "32", "a33" ], ]; my $outputfile = "output.xls"; my $workbook = Spreadsheet::WriteExcel->new($outputfile); my $worksheet = $workbook->addworksheet("a test"); my $number = $workbook->addformat( font => "Helvetica", size => 18, num_format => "0.00", align => "right", ); my $string = $workbook->addformat( font => "Helvetica", size => 18, align => "left", bold => 1, ); my $format = [ [ $string, $number, $string ], [ 16, 12, 16 ] ]; my $line; for my $row (@$arr) { $worksheet->write_formatted_row( 3 + $line++, 0, $row, $format ); } $workbook->close(); chomp( my $pwd = `pwd` ); my $file = $pwd . $outputfile; $^O =~ /Mac/ and MacPerl::DoAppleScript( <[1] } ) { my $colwidth = $format->[1][$col]; $self->set_column( $colstart + $col, $colstart + $col, $colwidth, undef ); } $width_is_set = 1; } for my $col ( 0 .. $#arr ) { my $colformat = $format->[0][$col]; die "parameter error: no format objects specified\n" unless ref $colformat eq 'Spreadsheet::WriteExcel::Format'; $self->write( $rowstart, $colstart + $col, $arr[$col], $colformat ); } }