Take a few minutes and try to read your own post, can you read it easily? Others who are trying to help will not have the patience to read through such formats. Please check Writeup Formatting Tips
I have put junk values into all of the arrays that you did not provide to us
#!/usr/bin/perl use strict; # USE IT ALL THE TIME use warnings; # USE IT ALL THE TIME use Spreadsheet::WriteExcel; my @model = qw (some random text goes here what else?); my @processor = qw (some random text goes here what else?); my @memory = qw (some random text goes here what else?); my @softwareVersion = qw (some random text goes here what else?); my @devicesPerVariant = qw (some random text goes here what else?); my $devicePerModel = "Hello"; my $workbook = Spreadsheet::WriteExcel->new("test.xls") or die $!; my $worksheet = $workbook->add_worksheet(); my $j = 0; my $rowCounter = 1; #### Declare rowcounter. O/W It is undef the fir +st time around $worksheet->write(0,0 , 'Equipment Model'); $worksheet->write(0,1, 'Devices Per Model'); $worksheet->write(0,2, 'Devices Per Variant'); $worksheet->write(0,3, 'Model Variant Processor'); $worksheet->write(0,4 , 'Device Memory'); $worksheet->write(0,5 , 'Device Software'); for ($j = 1; $j <= $#model; $j++) { $worksheet->write($rowCounter,0, $model[$j]); ### You start with $j = 1 then why are you checking for this????? if ($j == 0) { $worksheet->write($rowCounter,1, $devicePerModel); } # Are you sure that all of your arrays have the same length? $worksheet->write($rowCounter,2, $devicesPerVariant[$j]); $worksheet->write($rowCounter,3, $processor[$j]); $worksheet->write($rowCounter,4, $memory[$j]); $worksheet->write($rowCounter,5, $softwareVersion[$j]); $rowCounter++; } $workbook->close();
The excel output :
| Equipment Model | Devices Per Model | Devices Per Variant | Model Variant Processor | Device Memory | Device Software |
| random | random | random | random | random | |
| text | text | text | text | text | |
| goes | goes | goes | goes | goes | |
| here | here | here | here | here | |
| what | what | what | what | what | |
| else? | else? | else? | else? | else? |
What is wrong with this output?
In reply to Re: problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows
by sk
in thread problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows
by adamlee14
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |