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

That is a start in the right direction. But do you really not use any indentation? Do you really need 200 lines of code to demonstrate the problem? Try stripping out as much code as you can and still show the problem.

For a start, do you really need to populate 6 columns of data? Bet you can get away with 1. Do you really need to use any modules? Bet you can reproduce it with just print and a little hardwired data.

Actually, by the time you have stripped the code down to just that required to demonstrate the problem I can almost guarante that you will find the problem yourself. If you don't, then post the reduced code, the output you get, and the output you expect; then everyone will understand your problem and will be able to reproduce it. In a case like this it is rather unlikely to be one of the myriad modules that you are using.


Perl is Huffman encoded by design.
  • Comment on Re^3: problem using perl module Spreadsheet::WriteExcel cannot get data into rows when using for loop on a list to populate rows

Replies are listed 'Best First'.
Re^4: 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 07:04 UTC
    Hi i sent all the code just to present a picture i what i was trying to achieve i dont know if i can send excel spreadsheet that indicate the problem i have but simply the code is not writing to the spreadsheet here is the problem code.. only the first row and the last row nothing in between sub populateExcelRows {
    my $workbook = Spreadsheet::WriteExcel->new("test.xls");
    my $worksheet = $workbook->add_worksheet();
    my $j = 1;
    #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
    for ($j = 1; $j <= $#model; $j++)  {
     print "row is $rowCounter, $model[$j], $devicesPerVariant[$j], $processor[$j], $memory[$j], <code>$softwareVersion[$j]\n";
    $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();
    here is some rows iam trying to put in the spreadsheet row is 1, GSR, 2, GRP, 256Mb, 12.0(26)S3
    row is 1, 6503, 13, WS-X6K-SUP2-2GE, 128Mb, 7.6(8)
    row is 1, 2651, 68, MPC860P, 128Mb, 12.3(6)
    row is 1, ERX1400, 11, SRP-10Ge, 512Mb, 5.1.3 S-2.0
    row is 3, ERX1400, 36, SRP-10Ge, 512Mb, 5.1.3 S-2.2

      One thing that you should try is replacing all the $worksheet->write lines with equivelent print lines so that you can see if the problem is in writing the data or in generating it.

      The smaller and simpler you can make your test code, the easier it will be to isolate the problem. Copy the code to a different file, then cut lines out and simplify the code until the problem goes away.

      This is a generally useful debugging technique for otherwise intractable problems and makes it much easier to generate a simple test case for reporting the problem.


      Perl is Huffman encoded by design.
        Hi I have done this by using the following ... for ($j = 1; $j <= $#model; $j++)  {
         print "row is $rowCounter, $model[$j], $devicesPerVariant[$j], $processor[$j], $memory[$j], <code>$softwareVersion[$j]\n";
        within the for loop and i know its reading the global variable and prints to the screen seen .. row is 1, GSR, 2, GRP, 256Mb, 12.0(26)S3
        row is 2, 6503, 13, WS-X6K-SUP2-2GE, 128Mb, 7.6(8)
        row is 3, 6503, 10, WS-X6K-SUP2-2GE, 256Mb, 7.6(8)
        row is 4, 2651, 68, MPC860P, 128Mb, 12.3(6)
        row is 5, ERX1400, 11, SRP-10Ge, 512Mb, 5.1.3 S-2.0
        row is 6, ERX1400, 1, SRP-10Ge, 384Mb, 5.1.3 S-2.2
        row is 7, ERX1400, 36, SRP-10Ge, 512Mb, 5.1.3 S-2.2
        row is 8, 6509, 16, WS-X6K-SUP1A-2GE, 128Mb, 7.6(8)
        row is 9, 6509, 12, WS-X6K-SUP2-2GE, 128Mb, 7.6(8)
        row is 10, 6509, 12, WS-SUP720-3BXL, 1Gb, 8.4(1)
        row is 11, 10K, 54, PRE1-RP, 512Mb, 12.0(20050225:232036)
        row is 12, 3550, 56, PowerPC, 64Mb, 12.1(11)EA1
        row is 13, 3550, 26, PowerPC, 64Mb, 12.1(13)EA1c
        row is 14, 6506, 14, WS-X6K-SUP1A-2GE, 128Mb, 7.6(8)
        row is 15, 7206, 2, NPE-G1, 256Mb, 12.3(6b)
        row is 16, 7206, 6, NPE400, 128Mb, 12.3(6b)
        row is 17, 7606, 1, R7000, 256Mb, 12.1(22)E1
        row is 18, 7606, 3, R7000, 512Mb, 12.1(22)E1
        row is 19, ERX705, 40, SRP-5GPlus, 512Mb, 5.1.3 S-2.2
        row is 20, ERX700, 4, SRP-10Ge, 512Mb, 5.1.3 S-2.2
        row is 21, 3524, 2, PowerPC403, 8Mb, 12.0(5.2)XU
        the spreadsheet still just prints the first row and how do you send a excel spread sheet to show what i mean