01下载excel类,将Classes文件夹放入ThinkPHP\Extend\Vendor\位置
下载地址 http://phpexcel.codeplex.com/releases/view/26478,
02
public function uploadFile(){
$filetmpname = WEB_PATH.'abc.xls';
Vendor('Classes.PHPExcel');
$objPHPExcel = \PHPExcel_IOFactory::load($filetmpname);
$arrExcel = $objPHPExcel->getSheet(0)->toArray();
echo '<meta http-equiv="Content-type" content="text/html:charset=utf-8">';
echo '<pre>';
var_dump($arrExcel);exit;
//删除不要的表头部分,我的有三行不要的,删除三次
array_shift($arrExcel);
array_shift($arrExcel);
array_shift($arrExcel);//现在可以打印下$arrExcel,就是你想要的数组啦
echo '<meta http-equiv="Content-type" content="text/html:charset=utf-8">';
echo '<pre>';
// var_dump($arrExcel);exit;
$model = M('account');
foreach($arrExcel as $k=>$v){
$add['account_name'] = $v[0];
$add['account_mobile'] = $v[1];
$add['account_createtime'] = date('Y-m-d H:i:s',time());
$model->add($add);
echo M()->getLastSql();
echo '<br/>';