use strict; use warnings; use diagnostics; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add(); for (2..$wb->Sheets->{Count}) { $wb->Sheets(2)->Delete; } my $worksheet = $wb->Sheets(1); my %hash = (1 => 'One', 5 => 'Five', 10=> 'Ten'); my $row = 0; foreach my $key (sort keys %hash){ $row = $row + 1; print "Key: $key\nValue: $hash{$key}\n"; $worksheet->Cells($row, $key)->{Value} = $hash{$key}; }