public function actionImportExcelToMysql()
{
$filename = './1.xlsx';
$objPHPExcelReader = PHPExcel_IOFactory::load($filename);
$reader = $objPHPExcelReader->getWorksheetIterator();
//循环读取sheet
foreach($reader as $sheet) {
//读取表内容
$content = $sheet->getRowIterator();
//逐行处理
$res_arr = array();
foreach($content as $key => $items) {
$rows = $items->getRowIndex(); //行
$columns = $items->getCellIterator(); //列
$row_arr = array();
//确定从哪一行开始读取
if($rows < 2){
continue;
}
//逐列读取
foreach($columns as $head => $cell) {
//获取cell中数据
$data = $cell->getValue();
$row_arr[] = $data;
}
$res_arr[] = $row_arr;
}
}
foreach ($res_arr as $value) {
$model = new PrManageHospitalCopy();
$model->hospital_name = $value[0];
$model->save(false);
}
}