LOADING STUFF...

phpexcel导入excel处理大数据(实例讲解)

技术教程13小时前发布 北陌
23 0 0

phpexcel导入excel处理大数据(实例讲解)

先下载对应phpExcel 的包就行了https://github.com/PHPOffice/PHPExcel

下载完成 把那个Classes 这个文件夹里面的 文件跟文件夹拿出来就好了。

直接写到PHPExcel 这个文件里面的。调用很简单。引入phpExcel 这个类传递对应的excel 文件的路径就好了

现在上传到指定的目录,然后加载上传的excel文件读取这里读取是的时候不转换数组了。注意:是Sheet可以多个读取,php上传值要设置大,上传超时要设置长。

header(Content-type: text/html; charset=utf-8); //设置页面编码
require_once phpexcel.class.php; //引入文件
require_once PHPExcel/IOFactory.php; //引入文件
require_once PHPExcel/Reader/Excel2007.php; //引入文件
$uploadfile = $_FILES[select_file][tmp_name]; //获取上传文件
$auid = $_SESSION[auid];
$date = date(Ymd);
$rand = rand(1,9999);
$_month=str_replace(-,,$date);
$file_name = str_pad($auid, 4, 0, STR_PAD_LEFT).$date.str_pad($rand, 4, 0, STR_PAD_LEFT)..xlsx;
$path_file = ../data/upload/file/.$file_name; //上传文件目录指定
move_uploaded_file($uploadfile, $path_file); //文件上传

$inputFileType = PHPExcel_IOFactory::identify($path_file);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader-

© 版权声明

相关文章

暂无评论

暂无评论...