in reply to Re^3: Direct to spreadsheet
in thread Direct to spreadsheet
I had to comment out the bit where I'm getting rid of unwanted text because I'm not sure how to handle this now I'm reading from an array rather than a filehandle. I'd really like to reinstate this# Create the spreadsheet and set up formats $workbook = Spreadsheet::WriteExcel->new("my.xls"); # Set up various workbook formats here.... # Create some worksheets $sheet1 = $workbook->add_worksheet('Tools'); $sheet2 = $workbook->add_worksheet('Client'); $sheet3 = $workbook->add_worksheet('Fares'); # create some column headings for each worksheet here... # Set up some lookup lists using Regexp::List here... # execute the select statement my @data2; $sth=$dbh->prepare($sqlcmd); $sth->execute; $sth->bind_columns ( \( $sp, $ev, $seq, $log, $db, $ex) ); while ($sth->fetchrow_arrayref) { chomp $ex; $ex =~ tr/\t//; # get rid of the tabs in the ex part of the record if ( $seq > 1) { push @data2, "$ex"; } else { push @data2, "\nBOR $ev|$sp|$log|$db|$seq|$ex"; } } $sth->finish; $dbh->disconnect; $/="BOR "; for (@data2) { chomp; # if( m[/\-] ) { # $_ .= <TXT> until m[\-/]; # s[ \s? / \- .+? \- / \s? ][]smgx;# cut out some unwanted txt # chomp; #} my @rec = split /\|/; $aa = $rec[0]; $bb = $rec[1]; $cc = $rec[2]; $dd = $rec[3]; # $rec[4] isn't used here $ee = $rec[5]; if ($ee =~ /$regexp1/) { popxls($sheet1,$normal,$darow); # populate worksheet 1 $darow++; } elsif ($ee =~ /$regexp2/) { popxls($sheet2,$normal,$arow); # populate worksheet 2 $arow++; } elsif ($ee =~ /$regexp3/) { popxls($sheet3,$normal,$srow); # populate worksheet3 $srow++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Direct to spreadsheet
by McDarren (Abbot) on Jan 23, 2006 at 17:22 UTC |