public function import_excel(){
if (!$_FILES["file"]["name"]) {
echo "Please upload excel file !";
} else {
$path = $_FILES["file"]["tmp_name"];
$object = PHPExcel_IOFactory::load($path);
foreach ($object->getWorksheetIterator() as $worksheet) {
$highestRow = $worksheet->getHighestRow();
$highestColumn = $worksheet->getHighestColumn();
for ($row = 2; $row <= $highestRow; $row++) {
$group = $worksheet->getCellByColumnAndRow(0, $row)->getValue();
$merchant_id = $worksheet->getCellByColumnAndRow(1, $row)->getValue();
$login_id = $worksheet->getCellByColumnAndRow(2, $row)->getValue();
$play_id = $worksheet->getCellByColumnAndRow(3, $row)->getValue();
$mem_name = $worksheet->getCellByColumnAndRow(4, $row)->getValue();
$data[] = array(
'group' => $group,
'merchant_id' => $merchant_id,
'login_id' => $login_id,
'play_id' => $play_id,
'mem_name' => $mem_name,
);
}
}
$this->db->insert_batch('excel_files', $data);
}
}
此代码在上传excel时有效,但我想知道当用户上传excel 50行时,第二天再次上传65行,65行不需要重复。