Problem when using and creating nested (anonymous) arrays.
moller_at_notvalid.se
Date: 02/18/04
- Next message: moller_at_notvalid.se: "Re: Using a nested array to paste range in Excel"
- Previous message: moller_at_notvalid.se: "Using a nested array to paste range in Excel"
- Next in thread: Gunnar Hjalmarsson: "Re: Problem when using and creating nested (anonymous) arrays."
- Reply: Gunnar Hjalmarsson: "Re: Problem when using and creating nested (anonymous) arrays."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 18 Feb 2004 00:14:11 GMT
I'm reposting this under a more appropriate subject
since excel really has nothing to do with my problem.
I'm new to perl but not to programming in general.
I have been trying to put some data into an excel
***. And it works fine.... if I hardcode the data.
And I of cource I dont want to do that.
This code works:
my $table = [["040101",11,12,13,14,15],
["040102",21,22,23,24,25],
["040103",31,32,33,34,35],
["040104",41,42,43,44,45],
["040105",51,52,53,54,55]];
$***->Range("A3:E7")->{Value} = $table;
So my (probably stupid) question is:
How do I create the $table array dynamicly?
foreach (sort (keys %My_hash)) {
my $A = $My_hash{$_} { data_a };
my $B = $My_hash{$_} { data_b };
my $C = $My_hash{$_} { data_c };
my $D = $My_hash{$_} { data_d };
my $E = $My_hash{$_} { data_e };
And here I would like to create each "row" in the array
}
I have tried using an normal array like this but this goes wrong.
I get nonsens data in my excel file.
my @arr;
foreach (sort (keys %My_hash)) {
my $A = $My_hash{$_} { data_a };
my $B = $My_hash{$_} { data_b };
my $C = $My_hash{$_} { data_c };
my $D = $My_hash{$_} { data_d };
my $E = $My_hash{$_} { data_e };
push @arr, [$_, $A, $B, $C, $D, $D];
}
$***->Range("A3:E7")->{Value} = @arr;
I'm quite sure ther is somthing basic I'm missing.
Any suggestions apreciated.
- Next message: moller_at_notvalid.se: "Re: Using a nested array to paste range in Excel"
- Previous message: moller_at_notvalid.se: "Using a nested array to paste range in Excel"
- Next in thread: Gunnar Hjalmarsson: "Re: Problem when using and creating nested (anonymous) arrays."
- Reply: Gunnar Hjalmarsson: "Re: Problem when using and creating nested (anonymous) arrays."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]