--- sql2xls.cgi 2008/03/24 14:05:54 1 +++ sql2xls.cgi 2008/03/24 15:57:14 2 @@ -10,6 +10,12 @@ use DBI; use CGI::Carp qw(fatalsToBrowser); use CGI qw(path_translated); +use Encode qw/decode/; + +# Connect to DB +my $connect = "DBI:Pg:dbname=new"; +my $user = "web"; +my $passwd = ""; my $debug = 1; @@ -30,13 +36,12 @@ $workbook = Spreadsheet::WriteExcel->new("sql_result.xls"); } -# Connect to DB -my $connect = "DBI:Pg:dbname=new"; -my $user = "web"; -my $passwd = ""; - my $dbh = DBI->connect($connect,$user,$passwd) || die $DBI::errstr; +sub _c { + return decode('iso-8859-2', shift); +} + foreach my $sql_file (@sql_files) { my $sheet_name = $sql_file; @@ -72,7 +77,7 @@ my $fmt_comment = $workbook->addformat(); # Add a format $fmt_comment->set_bold(); - $worksheet->write($row, 0, $comment, $fmt_comment); + $worksheet->write($row, 0, _c($comment), $fmt_comment); $row+=2; } @@ -89,7 +94,7 @@ while (my @row = $sth->fetchrow_array() ) { for(my $col=0; $col<=$#row; $col++) { - $worksheet->write($row, $col, $row[$col] ); + $worksheet->write($row, $col, _c( $row[$col] ) ); } $row++; }