Before we get into the code... When you submitted you post did you see something like this? If something looked unlike you expected it to you might need to check out Writeup Formatting Tips ?

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 ModelDevices Per ModelDevices Per VariantModel Variant ProcessorDevice MemoryDevice Software
randomrandomrandomrandomrandom
texttexttexttexttext
goesgoesgoesgoesgoes
hereherehereherehere
whatwhatwhatwhatwhat
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.