in reply to problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows

OK, first up:
for ($j = 1; $j <= $#model; $j++) { $worksheet->write($rowCounter,0, $model[$j]);

The $rowCounter variable does appear to be defined, so it will be zero to start with. So all the effort you went into to write 'Equipment Model' to cell(0,0) will be erased by the first model name.

Why are you using $rowCounter? If you replace $rowCounter with $j does it make your life easier?

Are your arrays (@devicesPerVariant, @processor, @memory, and @softwareVersion) indexed by 0 or 1? You appear to be accessing them from element 1 onwards (for ( $j = 1; ...).

Have you tried use strict; and ensured your program compiles with no errors.. (e.g. perl -wc script.pl).

  • Comment on Re: problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows
by adamlee14 (Initiate) on Sep 14, 2005 at 04:56 UTC
    1) rowCounter is a global variable that keep track of what row I'm upto in the spreadsheet because the function is called multiple times to populate all data. 2) rowcounter isn't being replaced. J is just being used as a local counter whilst rowcounter keeps track globally. 3) All arrays are the same size and the first index is just "". Don't know howe to initialize a blank array, so I use "@array = ""; ". This just makes the first value "" and hence I start at index 1 instead of 0. 4) No I haven't used "use strict". It seems to output lots of errors like "requires explicit package name at ./XXXXXXXX.pl line XX". These don't seem to me like legitimate errors. I could be wrong :-)
Re^2: problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows
by adamlee14 (Initiate) on Sep 14, 2005 at 01:58 UTC
    Hi thanks for the reply i tried using J instead of rowcounter , it does the same thing the excel spreadsheet only get the final row here is the eaxample printed output that i want to fill a spreadsheet with Hardware type is GSR
    Devices = 12
    Unique Device counts = 10 2
    Unique Device models = GSR GSR
    Unique Device processors = GRP GRP
    Unique Device memory = 128Mb 256Mb
    Unique Device software = 12.0(26)S3 12.0(26)S3
    Model is 1
    row is 1, GSR, 2, GRP, 256Mb, 12.0(26)S3
    Hardware type is 6503
    Devices = 23
    Unique Device counts =  13 10
    Unique Device models =  6503 6503
    Unique Device processors =  WS-X6K-SUP2-2GE WS-X6K-SUP2-2GE
    Unique Device memory =  128Mb 256Mb
    Unique Device software =  7.6(8) 7.6(8)
    Model is 2
    row is 1, 6503, 13, WS-X6K-SUP2-2GE, 128Mb, 7.6(8)
    Hardware type is 2651
    Devices = 68
    Unique Device counts =  68
    Unique Device models =  2651
    Unique Device processors =  MPC860P
    Unique Device memory =  128Mb
    Unique Device software =  12.3(6)
    Model is 1
    row is 1, 2651, 68, MPC860P, 128Mb, 12.3(6)
    Hardware type is ERX1400