实现功能:上传EXCEL文件,并按照格式导入到数据库中
在网上查找到phpecel 但是phpexcel实在是太大,自身能力有限不能很好的精简,最终找到了phpexcelreader这个类;非常小又能实现我需要的功能
第一步、下载phpexcelReader类(后面给出)
第二步、创建add.php写入如下代码:
$str=$_FILES['excelname']['tmp_name'];
$data = new Spreadsheet_Excel_Reader($str);
$data_arr = $data->sheets;
$all_data = $data_arr[0]['cells'];
foreach($all_data as $ak=>$av){
组织sql语句
}$data->sheets将excel里面的内容以数据形式输出;
$data->dump(true,true); 将excel里面的内容以html形式输出;
第三步、编写html上传文件
* 请选择文件: | |
写好的例子:http://yun.baidu.com/share/link?shareid=3068641847&uk=2903375990