注意:PHP7.4以上会报 Array and string offset access syntax with curly braces is deprecated
PHP7.4不再支持使用大括号访问数组以及字符串的偏移_PHP代码
php7.4不支持数组{}写法,统一为数组[]
1,到github下载PHPExcel
2,拷贝Classes中的PHPExcel 文件夹 和 PHPexcel.php 放在项目中的 sw_application\libraries 里面
$this->load->library('PHPExcel');
$objPHPExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($fileName);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
for ($currentRow = 2; $currentRow <= $highestRow; $currentRow++) {
$Info = $this->Message_Model->NewModel();
$Info['Model'] = "Report";
$Info['UserID'] = $this->get_string("ID");
$Info['UserName'] = $this->get_string("UserName");
$Info['OrderNo'] = $objPHPExcel->getActiveSheet()->getCell("A" . $currentRow)->getValue();
$Info['Province'] = $objPHPExcel->getActiveSheet()->getCell("B" . $currentRow)->getValue();
$Info['Company'] = $objPHPExcel->getActiveSheet()->getCell("C" . $currentRow)->getValue();
$Info['Name'] = $objPHPExcel->getActiveSheet()->getCell("D" . $currentRow)->getValue();
$Info['Mobile'] = $objPHPExcel->getActiveSheet()->getCell("E" . $currentRow)->getValue();
$Info['DealerProvince'] = $objPHPExcel->getActiveSheet()->getCell("F" . $currentRow)->getValue();
$Info['DealerCompany'] = $objPHPExcel->getActiveSheet()->getCell("G" . $currentRow)->getValue();
$Info['DealerName'] = $objPHPExcel->getActiveSheet()->getCell("H" . $currentRow)->getValue();
$Info['DealerEmail'] = $objPHPExcel->getActiveSheet()->getCell("I" . $currentRow)->getValue();
$Info['DealerMobile'] = $objPHPExcel->getActiveSheet()->getCell("J" . $currentRow)->getValue();
$Info['TypeNo'] = $objPHPExcel->getActiveSheet()->getCell("K" . $currentRow)->getValue();
$Info['State'] = $objPHPExcel->getActiveSheet()->getCell("L" . $currentRow)->getValue();
$Info['AddDate'] = $objPHPExcel->getActiveSheet()->getCell("M" . $currentRow)->getValue();
$Info['ExpireDate'] = $objPHPExcel->getActiveSheet()->getCell("N" . $currentRow)->getValue();
$Info['Detail'] = $objPHPExcel->getActiveSheet()->getCell("O" . $currentRow)->getValue();
$Info['Source'] = $objPHPExcel->getActiveSheet()->getCell("P" . $currentRow)->getValue();
$Info['SourceType'] = $objPHPExcel->getActiveSheet()->getCell("Q" . $currentRow)->getValue();
$Info['Address'] = $objPHPExcel->getActiveSheet()->getCell("R" . $currentRow)->getValue();
$add = $this->Message_Model->Add($Info);
}