/[SQL2XLS]/sql2xls.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sql2xls.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by dpavlin, Mon Mar 24 14:05:54 2008 UTC revision 2 by dpavlin, Mon Mar 24 15:57:14 2008 UTC
# Line 10  use Spreadsheet::WriteExcel; Line 10  use Spreadsheet::WriteExcel;
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    
# Line 30  if ($0 =~ m/\.cgi$/i) { Line 36  if ($0 =~ m/\.cgi$/i) {
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;
# Line 72  foreach my $sql_file (@sql_files) { Line 77  foreach my $sql_file (@sql_files) {
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    
# Line 89  foreach my $sql_file (@sql_files) { Line 94  foreach my $sql_file (@sql_files) {
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          }          }

Legend:
Removed from v.1  
changed lines
  Added in v.2

  ViewVC Help
Powered by ViewVC 1.1.26