I have code that is using Spreadsheet::WriteExcel here is a snippit..

sub populateExcelRows { my $workbook = Spreadsheet::WriteExcel->new("t +est9.xls"); my $worksheet = $workbook->add_worksheet(); my $j = 0; #Declare Headings for row 0 and the 6 Columns $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'); #Loop through Global Array called Models to determine the number of + rows to place data print "Model is $#model\n"; for ($j = 1; $j <= $#model; $j++) { $worksheet->write($rowCounter,0, $model[$j]); if ($j == 0) { $worksheet->write($rowCounter,1, $devicePerModel); } $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 following section using eg $worksheet->write(0,0 , 'Equipment Model');
writes a column headings this is OK then when i use eg -

for ($j = 1; $j <= $#model; $j++) { $worksheet->write($rowCounter,0, $model[$j]); if ($j == 0) { $worksheet->write($rowCounter,1, $devicePerModel); } $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(); }

this does only places data into the very last rows and leaves the 20 something rows all blank i know that the loop is accessing the data that should go into the spreadsheet by way of seeing it on the screen using a debug like #print "row is $rowCounter, $model[$j], $devicesPerVariant[$j], $processor[$j], $memory[$j], $softwareVersion[$j]\n";
the spreadsheet which i can send are all blank bar the first column headings and the very last row

Edit: g0n - replaced code tag on each line with blocks


In reply to 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.