Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003

    Unanswered: MySQL + SpreadSheet::WriteExcel Problems

    I'm attempting to write a script to pull information from a MySQL database, and write that array to a line in Excel. The script works, but it will not write the entire array. It always skips one line of data.

    Here is the code responsible:

    $sqlsheet1 = "SELECT ...."
    $stsheet1 = $dbwrite->query($sqlsheet1);
    @sheet1 = $stsheet1->fetchrow;

    my $row1 = 1;
    my $column1 = 0;
    while (@sheet1=$stsheet1->fetchrow) {
    $worksheet1->write($row1, $column1, \@sheet);

    The SELECT statement works from the mysql command line. I'm relatively new to Perl, so I know the code may not be the cleanest. Any help is greatly appreciated. Thanks,


  2. #2
    Join Date
    Sep 2003
    Your row counter should start at zero.


  3. #3
    Join Date
    Oct 2003
    Thanks, Matt. I guess I should clarify. The title columns are in Row 0.

    Row 0: Titles -- Server, Drive Letter, Partition, Total Space, Free Space, Percent Used.

    Rows 1++ should be the information pulled from the database. Even with $row1 set to 0, it truncates the first row of data. Thanks.
    Last edited by drangel1; 10-02-03 at 14:34.

  4. #4
    Join Date
    Oct 2003

    More info...

    Even if I change the Excel write statement to

    for (0..5) {
    $worksheet1->write($row1, $_, $sheet1[$_])

    for writing the database contents, the first record gets eliminated. Has anyone else experienced anything similar with use Mysql?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts