Welcome to the Oracle community forum and interact with the 2 million technical staff. This script is a tool for generating excelxls files using Perl. Depending on some modules, you can use it in linux to generate xls files. The command line + parameter is used. Very convenient. #! Usrbinperl # mysqlto
Welcome to the Oracle community forum and interact with 2 million technical staff> This script is a tool for generating excel xls files using Perl. Depending on some modules, you can use it in linux to generate xls files. The command line + parameter is used. Very convenient. #! /Usr/bin/perl #==================================#mysql to
Welcome to the Oracle community forum and interact with 2 million technical staff> enter
This script uses Perl to generate excel xls files. Depending on some modules, you can use it in linux to generate xls files. The command line + parameter is used. Very convenient.
#! /Usr/bin/perl
#====================================
# Mysql to excel
# Lastmodify at 2005-1-5
# Copyright by hoowa
#==================================
Use strict; # strict syntax check
Use DBI; # Database Engine
Use Unicode: Map; # Unicode Engine
# Use Spreadsheet: WriteExcel; # Excel report Engine
Use Spreadsheet: WriteExcel: Big; # large file Excel report Engine
My $ hostname = '2014. 168.1.20 ';
My $ username = 'user ';
My $ password = 'pass ';
My $ dbname = 'db ';
My $ trans_compress = 1; # transfer and compression between the database and the program from a non-zero number
$ | = 1;
My @ cols = ('a: A', 'B: B', 'c: C', 'd: d', 'e: e', 'f: f', 'G: G', 'H: H', 'I: I', 'J: J ',
'K: K', 'l: L','m: m', 'N': n', 'O: O', 'P: P', 'q: q', 'r: R','s: s','t: t', 'U: U ',
'V: V', 'W: W', 'x: x', 'y: y', 'z: Z', 'aa: A', 'bb: B ', 'CC: C', 'dd: d', 'ee: e ',
'Ff: f', 'gg: G', 'hh: H', 'II: I ', 'JJ: J', 'kk: K','ll: l', 'Mm: m', 'nn: n ',
'Oo: O', 'pp: P', 'qq: Q', 'rr: R', 'ss: s', 'tt: t', 'uu: u', 'vv: V', 'ww: W ',
'Xx: x', 'yy: y', 'zz: Z ');
# Parsed content
If ($ # ARGV! = '1 '){
Print qq ~ Syntax: my2excel. pl "[Where expression]"
~;
Exit;
}
$ ARGV [1] = ~ S/\ "// g;
Warn qq ~
Mysql to excel
By hoowa. sun
==================================
SQL: $ ARGV [1]
~;
My $ dbh =
DBI-> connect ("DBI: mysql: mysql_compression = $ trans_compress;
Database = $ dbname; host = $ hostname ", $ username, $ password );
My $ something = $ dbh-> prepare ("$ ARGV [1]") | die $ dbh-> errstr;
My $ rows = $ something-> execute () or die $ something-> errstr;
Warn "rows: $ rows found. \ n ";
My @ cols_name =@{$ something-> {'name '}};
If ($ # cols_name >$ # cols ){
Print "table $ ARGV [1] fields out of allow !! (Max num.> ". ($ # cols + 1).") \ n ";
Exit;
}
[1] [2]