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
sheet. 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]];
$Sheet->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];
}
$Sheet->Range("A3:E7")->{Value} = @arr;
I'm quite sure ther is somthing basic I'm missing.
Any suggestions apreciated. 1 1910 mo****@notvalid.se wrote: I have been trying to put some data into an excel sheet.
<snip>
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]];
$Sheet->Range("A3:E7")->{Value} = $table;
$table is a *reference* to an array of array references.
<snip>
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]; }
$Sheet->Range("A3:E7")->{Value} = @arr;
Try to use a *reference* to the array of array references:
$Sheet->Range("A3:E7")->{Value} = \@arr;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mjcsfo |
last post by:
I can't seem to find a reference nor any helpful threads on this
topic.
I've gotten the following error in two circumstances:
1. A complex type has nested within it another complex type, in the...
|
by: Julian Smith |
last post by:
I've been playing with a function that creates an anonymous function by
compiling a string parameter, and it seems to work pretty well:
def fn( text):
exec 'def foo' + text.strip()
return foo
...
|
by: elixxir |
last post by:
Hiho,
I'm trying to deserialize the following XML feed from the weather
channel but I'm having an issue with the nested arrays. I got as far as
getting the 'day' into arrays but I can't get the...
|
by: neverstill |
last post by:
hi-
I have <a> tags in my DataList. For the href property, I want to do
something like this:
<a href='~/Default.aspx?show=Support&disp=Faq&p=<%#
DataBinder.Eval(Container.DataItem, "name")%>'...
|
by: Vishal |
last post by:
Hello,
I already asked this question in the ASP.NET forums,
but no help came. So I am hoping that somebody can help me
out. This is really very URGENT me.
For my e-commerce application, I...
|
by: Les P |
last post by:
Hi,
Since '95 I have been a contractor develoing applications using Borland
Delphi (Object Pascal) creating win32 C/S stuff.
Having recently completed amy last contract I decided to try my hand at...
|
by: Ryan Shaw |
last post by:
I’m having a small problem with inheritance with a hierarchy of classes
The example is
Class Class
Private m_classB as Class
Class Class
End Clas
End Clas
|
by: =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= |
last post by:
Hi,
I need to initialize my class level dictionary (in .Net 2.0). I wanted to
make it inline and employ anonymous methods as I do not use this code for
anything else. Something similar to the...
|
by: Scoots |
last post by:
I know the usually applied workaround for multiple definitions of
header files, but I have a problem on this one.
This time, I can't just ifndef the header file that defines my
structure.
So...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |