From: Jason Etheridge Date: Tue, 31 Mar 2020 20:14:00 +0000 (-0400) Subject: add a tab listing up to 65k rows of the actual data being summarized. Only for excel... X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=2e08e087f38a35f776e675577df0d4cfcf895263 add a tab listing up to 65k rows of the actual data being summarized. Only for excel, not the SQL output --- diff --git a/mig-bin/mig-quicksheet b/mig-bin/mig-quicksheet index a1b516c..22ed33e 100755 --- a/mig-bin/mig-quicksheet +++ b/mig-bin/mig-quicksheet @@ -286,6 +286,7 @@ sub write_worksheets { }; } + handle_list(); handle_columns(); if ($outfile) { @@ -319,6 +320,46 @@ exit 0; ############################################################################### +sub handle_list { + my $dbh = Mig::db_connect(); + my $sth = $dbh->prepare(" + SELECT * + FROM " . $MIGSCHEMA. "." . $table . " + LIMIT 65530; + "); + my $rv = $sth->execute() + || die "Error retrieving data from staging table: $!"; + my $list_sheet; + + $sheet_row_offset = 0; + $has_x_source = 0; + if ($outfile) { + print "Sheet: $table\n"; + $list_sheet = $workbook->add_worksheet( $table ); + } + + my $handle_headers = 1; + + while (my $data = $sth->fetchrow_hashref) { + if ($handle_headers) { + my $_idx = 0; + foreach my $col (sort keys %{ $data }) { + $list_sheet->write($sheet_row_start + $sheet_row_offset,$_idx++,$col,$bold); + } + $handle_headers = 0; + } + $sheet_row_offset++; + my $idx = 0; + foreach my $col (sort keys %{ $data }) { + my $cdata = $$data{$col}; + if (!defined $cdata) { $cdata = '\N'; } + if ($outfile) { + $list_sheet->write($sheet_row_start + $sheet_row_offset,$idx++,$cdata,$left); + } + } + } +} + sub handle_columns { my $dbh = Mig::db_connect(); my $sth = $dbh->prepare("