I want to add my data stored in a 2x2 array in Excel using Perl. I know how to open and add simple data. I can use this for a loop. But how can I do it elegantly?
This is what I'm trying to do.
$sheet->Range("A1:B"."$size")->{Value} = @$data;
or @data;
or {@data};
or {\@data};
where @datais a two-dimensional array.
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
unless (defined $ex) {
$ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
$book = $ex->Workbooks->Add;
$sheet = $book->Worksheets(1);
print "A1:B"."$size";
$sheet->Range("A1:B"."$size")->{Value} = @$data;
sunny
source
share