php代码
/* Report all errors except E_NOTICE */ error_reporting(E_ALL^E_NOTICE); $filename = $_GET['filename']; $xlsPath = $filename; //指定要读取的exls路径 //$type = 'Excel2007'; //设置要解析的Excel类型 Excel5(2003或以下版本)或Excel2007 $type = 'Excel5'; //引入excel类 include 'load.php'; include 'Classes/PHPExcel.php'; include 'Classes/PHPExcel/IOFactory.php'; $xlsReader = PHPExcel_IOFactory::createReader($type); $xlsReader->setReadDataOnly(true); $xlsReader->setLoadSheetsOnly(true); $Sheets = $xlsReader->load($xlsPath); //开始读取 $Sheet = $Sheets->getSheet(0)->toArray(); //读取第一个工作表(注意编号从0开始) 如果读取多个可以做一个循环0,1,2,3.... //得到二维数组,每个小数组是excel表格内容的一行 里面包含此行的每列的数据 echo ''; echo ''; echo '数量订单总数'; $data = array(); for($i=2;$i0){ $info[$val['name']] = ++$sum; }else{ $info[$val['name']] = --$sum; } } foreach($info as $key=>$val){ echo "".$key."".$val.""; }
登录后复制