This is a practical php tutorial to use excelfileparser to import excel into the database.
excel data acquisition demonstration
excel data acquisition demonstration
parese.php file
/**
* copyright (c) 2009,
* all rights reserved.
* File name:
* Summary:
*
* @author Saturday [url=mailto:ixqbar@hotmail.com]ixqbar@hotmail.com[/url]
* @version
*/public function parse()
{
/**
* $_files array description
* array(n) {
* ["Form file box name"] => array(5) {
* ["name"] => Submit file name
* ["type"] => Submit file type excel is "application/vnd.ms-excel"
* ["tmp_name"] => Temporary file name
* ["error"] => Error (0 successful 1 file too large exceeds upload_max_filesize 2 file too large exceeds max_file 3 upload incomplete 4 no file uploaded)
* ["size"] => File size (unit: kb)
* }
* }
*/
$return=array(0,'');
/**
* Determine whether to submit
* is_uploaded_file (file name) is used to determine whether the specified file is uploaded using the post method to prevent illegal submission. It is usually used together with move_upload_file to save the uploaded file to the specified path
*/
if(!isset($_files) || !is_uploaded_file($_files['excel']['tmp_name']))
{
$return=array(1,'Submission is illegal');
}
//Process
if(0 == $return[0])
{
import('@.util.excelparser');
$excel=new excelparser($_files['excel']['tmp_name']);
$return=$excel->main();
}
//Output processing
print_r($return);
?>