class IndexAction extends Action {
public function index(){
$this->display();
}
public function upload()
{
import("ORG.Net.UploadFile");
if(!empty($_FILES['photo']['name']))
{
$upload = new UploadFile();
$upload->maxSize = 93145728 ;
$upload->saveRule =time;
$upload->allowExts = array('xls','xlsx');
$upload->savePath = './Uploads/';
if(!$upload->upload())
{
$this->error($upload->getErrorMsg());
}else{
$info = $upload->getUploadFileInfo();
} www.111com.net
//下面就是我们说的第二步了
import("ORG.Excel.PHPExcel");
$file_name=$info[0]['savepath'].$info[0]['savename'];
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load($file_name,$encode='utf-8');
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
for($i=2;$i<=$highestRow;$i++)
{
$name = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$old = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue();
$sex = $objPHPExcel->getActiveSheet()->getCell("C".$i)->getValue();
$ID = $objPHPExcel->getActiveSheet()->getCell("D".$i)->getValue();
$guoji = $objPHPExcel->getActiveSheet()->getCell("E".$i)->getValue();
$minzu = $objPHPExcel->getActiveSheet()->getCell("F".$i)->getValue();
$address = $objPHPExcel->getActiveSheet()->getCell("G".$i)->getValue();
}
echo $name."//".$old."//".$sex."//".$ID."//".$guoji."//".$minzu."//".$address;exit;
}else
{
$this->error("请选择上传的文件");
}
}
}
|