I can't reproduce your problem. The following code runs and does what I think you say you ought to want, with a few minor tweaks, such as making the key correspond to the row, which makes things slightly easier for me. If you can show code that runs from scratch and demonstrates your problem, I might be able to do better.
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'); foreach my $key (sort keys %hash){ print "Key: $key\nValue: $hash{$key}\n"; $worksheet->Cells($key, 1)->{Value} = $hash{$key}; }
Regards,
John Davies
In reply to Re: Can't use an undefined value as a hash reference when passing hash key into Excel OLE call.
by davies
in thread Can't Use an undefined value as a HASH reference when passing HASH key into Excel OLE call.
by kgnickl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |