这是一款实用的php教程利用excelfileparser把excel导入数据库教程,代码如下:
- <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
- <html xmlns="http://www.111cn.net/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>excel数据获取演示</title>
- <meta name="keywords" content="todo" />
- <meta name="description" content="todo"/>
- </head>
- <body>
- <div>
- <div>excel数据获取演示</div>
- <div>
- <form method="post" action="/index/parse" enctype="multipart/form-data">
- <input type="file" name="excel" value="" />
- <input type="submit" name="submit" value="提交" />
- </form>
- </div>
- </div>
- </body>
- </html>
parese.php文件,代码如下:
- <?php
-
-
-
-
-
-
-
-
-
- public function parse()
- {
-
-
-
-
-
-
-
-
-
-
-
-
- $return=array(0,'');
-
-
-
-
- if(!isset($_files) || !is_uploaded_file($_files['excel']['tmp_name']))
- {
- $return=array(1,'提交不合法');
- }
-
- if(0 == $return[0])
- {
- import('@.util.excelparser');
- $excel=new excelparser($_files['excel']['tmp_name']);
- $return=$excel->main();
- }
-
- print_r($return);
- ?>
|