function read
()[align
=left
] { [/align
][align
=left
] $rows= array('id','sku','name','description','created_on','enabled');[/align
][align
=left
] $KeyWord_sku = 'sku'; //修改索引 $KeyWord_mac = 'name'; //修改索引
$KeyWord_des = 'description'; //修改索引
$fileName = EXCELFILE_PATH.'MyExcel.xlsx';
$filename = $_FILES['userfile']['name'];
$Exsel_data =$this->excel->read($fileName,$rows); //返回excel中的数据
//$this->FilterExsel($Exsel_data,$KeyWord_sku);
$DB_data = $this->mexcel->selUsers(); //查询DB中的全部数据
if(!empty($DB_data))
{
//$this->load->view('preview_form',$Exsel_data);
$DataKeyArray = $this->getKeyValue($DB_data,$KeyWord_sku,$KeyWord_mac,$KeyWord_des);//筛选所有的索引并组装成数组
$dataChange = $this->dataChange($DB_data,$KeyWord_sku,$KeyWord_mac,$KeyWord_des);
}
echo '<table border=1>
<tr>
<th colspan=4>'.$filename.'</th>
</tr>
<tr>
<th>SerialNumber</th>
<th>mac</th>
<th>description</th>
<th>status</th>
</tr>';
foreach($Exsel_dataas $Ekey =>$Evalue)
{
if(!$this->arrayEmpty($Evalue))
{
//判断excel中的数据在DB中时候存在 有则判断是否修改 反之增加
if(!empty($DB_data) &&$this->isExist($Evalue,$KeyWord_sku,$DataKeyArray))
{
//判断是否相同 相同则跳过,不相同则修改
if(!$this->isChange($Evalue,$dataChange,$KeyWord_sku))
{
//if($this->updExcel($Evalue))
echo'<td>'.$Evalue[$KeyWord_sku].'</td><td>'.$Evalue[$KeyWord_mac].'</td><td><center>'.$Evalue[$KeyWord_des].'</center></td><td>Alreadyexist.<tr>';
}
}
else
{
if($this->addExcel($Evalue))
echo '添加的资料:'.$Evalue[$KeyWord_sku].''.$Evalue[$KeyWord_mac].' '.$Evalue[$KeyWord_des].' 成功'.'<br>';
}
}
}
echo '</table>';
//echo'资料导入成功';
}