Writing Excel using COM

< ^ >

    #!/usr/bin/perl -w

    use strict;
    use Cwd;
    use Win32::OLE;
    use Win32::OLE::Const 'Microsoft Excel';

    my $data =  [
                    ['Area',    'Sales'      ],
                    ['East',    '150'        ],
                    ['West',    '100'        ],
                    ['Total',   '=SUM(B2:B3)'],
                ];

    my $application = Win32::OLE->new("Excel.Application");
    my $workbook    = $application->Workbooks->Add;
    my $worksheet   = $workbook->Worksheets(1);

    my $range = $worksheet->Range("A1:B4");
       $range->{Value} = $data;

    $workbook->SaveAs({FileName => cwd() . '/new_ole.xls'});
    $workbook->Close;


    __END__