Dear great ones, I have turned to the almighty Perl to make a spread sheet. It's made life incredibly easy for me up until now. I need to add data from files into columns. The problem is, I don't know how many columns there will be or how many files as the data I'm using for the files is variable. For example,
my $intStartRow = 0; my $altRow = $intStartRow; my $intStartCol = 2; my $altCol = $intStartCol; open (FRUITS, '/home/fruit_types.txt') or die ("Problem opening file: +$!"); # Fruit Header Insertion my $row = 1; while (<FRUIT>) { chomp; # Split on single tab my @Fld = split ('\t', $_); my $col = 3; foreach my $token (@Fld) { $worksheet->write($altRow, $altCol++, $token, $format); $col++; } $row++; }
So I have a file called fruit_types which contains the strings (apple, banana, orange, etc). The perl script will automatically put those strings into their own columns at the head of the spread sheet. The types of fruit will be variable so I will not know how many strings will be in the file, hence why it is added using the script above. I then have a directory with a separate file for each fruit i.e (apple.txt, banana.txt, orange.txt, etc). Inside each file contains spread sheet data (1,2,5, etc) to represent the amounts of each fruit I have. I now want to tie that data into the relevant column (apple, banana, orange, etc). The spread sheet would look like this...
Can someone enlighten me how I would go about doing this? Thanks, Richard.apple banana orange 1 2 5 2 3 8 3 1 3
In reply to Using variable files to add data into excel spreadsheet by rickyboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |