Php > Php Classes
Export Excel Dynamically to Csv then to mysql
Export Excel Dynamically to Csv then to mysql class Export_Excel { var $command function Export_Excel() { $this->command = "/xls2csv"; } function xls2csv($path,$xls_file,$short_name) { $cmd = escapeshellcmd("$this->command -q 0 $path.$xls_file"); $cmd .= " > $path.$short_name.csv"; @exec($cmd,$stdout,$errocode); unlink("$path.$xls_file"); if ($errorcode > 0) return $errocode; } } then in my db class function insert_file($filename,$table,$col_terminator,$line_terminator,$cols=false,$opt ions=false,$remove_file=false) { if ($options) $option = "OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; $this->query("LOAD DATA INFILE '$filename' INTO TABLE $table FIELDS TERMINATED BY '$col_terminator' $option $cols"); if ($remove_files) unlink($filename); } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage