10 |
use DBI; |
use DBI; |
11 |
use CGI::Carp qw(fatalsToBrowser); |
use CGI::Carp qw(fatalsToBrowser); |
12 |
use CGI qw(path_translated); |
use CGI qw(path_translated); |
13 |
|
use Encode qw/decode/; |
14 |
|
|
15 |
|
# Connect to DB |
16 |
|
my $connect = "DBI:Pg:dbname=new"; |
17 |
|
my $user = "web"; |
18 |
|
my $passwd = ""; |
19 |
|
|
20 |
my $debug = 1; |
my $debug = 1; |
21 |
|
|
36 |
$workbook = Spreadsheet::WriteExcel->new("sql_result.xls"); |
$workbook = Spreadsheet::WriteExcel->new("sql_result.xls"); |
37 |
} |
} |
38 |
|
|
|
# Connect to DB |
|
|
my $connect = "DBI:Pg:dbname=new"; |
|
|
my $user = "web"; |
|
|
my $passwd = ""; |
|
|
|
|
39 |
my $dbh = DBI->connect($connect,$user,$passwd) || die $DBI::errstr; |
my $dbh = DBI->connect($connect,$user,$passwd) || die $DBI::errstr; |
40 |
|
|
41 |
|
sub _c { |
42 |
|
return decode('iso-8859-2', shift); |
43 |
|
} |
44 |
|
|
45 |
foreach my $sql_file (@sql_files) { |
foreach my $sql_file (@sql_files) { |
46 |
|
|
47 |
my $sheet_name = $sql_file; |
my $sheet_name = $sql_file; |
77 |
my $fmt_comment = $workbook->addformat(); # Add a format |
my $fmt_comment = $workbook->addformat(); # Add a format |
78 |
$fmt_comment->set_bold(); |
$fmt_comment->set_bold(); |
79 |
|
|
80 |
$worksheet->write($row, 0, $comment, $fmt_comment); |
$worksheet->write($row, 0, _c($comment), $fmt_comment); |
81 |
$row+=2; |
$row+=2; |
82 |
} |
} |
83 |
|
|
94 |
|
|
95 |
while (my @row = $sth->fetchrow_array() ) { |
while (my @row = $sth->fetchrow_array() ) { |
96 |
for(my $col=0; $col<=$#row; $col++) { |
for(my $col=0; $col<=$#row; $col++) { |
97 |
$worksheet->write($row, $col, $row[$col] ); |
$worksheet->write($row, $col, _c( $row[$col] ) ); |
98 |
} |
} |
99 |
$row++; |
$row++; |
100 |
} |
} |