print 'File #' . $counter . "\n";
print "Sheet: Field Summary\n";
my $tab_name = (scalar(@ARGV) > 1 ? $counter . ') ' : '') . 'Field Summary';
+ $tab_name = substr($tab_name,0,31); # truncate for WriteExcel
if ($outfile) {
$first_sheet = $workbook->add_worksheet( $tab_name );
$first_sheet->set_column(0,6,30);
};
}
+ handle_list();
handle_columns();
if ($outfile) {
###############################################################################
+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("
my $col_sheet;
my $col_table;
- my $sheet_name = (scalar(@ARGV) > 1 ? $counter . ') ' : '') . substr($column,0,31);
+ my $sheet_name = (scalar(@ARGV) > 1 ? $counter . ') ' : '') . $column;
+ $sheet_name = substr($sheet_name,0,31);
print "Sheet: $sheet_name\n";
if ($has_x_source) {