adamlee14 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|