20,359
社区成员
发帖
与我相关
我的任务
分享
$uploadfile=$_FILES["file"]['tmp_name'];
if(is_uploaded_file($uploadfile) && $_POST['aid']){
Vendor('PhpExcel.PHPExcel');
Vendor('PHPExcel.IOFactory');
Vendor('PHPExcel.Reader.Excel5');
$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
$objPHPExcel = $objReader->load($uploadfile);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = 0; // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
$start=1;//从哪一行开始录入/删除
if($_POST['diyihang']){
//忽略第一行
$highestRow = $sheet->getHighestRow(); // 取得总行数
$start=2;
}else{
$highestRow= ($sheet->getHighestRow()); // 取得总行数
}
$update=array();
$delete=array();
//获取信息字段
$fresult=M("form")->where("aid = %d",$_POST['aid'])->order("sort")->select();
for($start;$start<=$highestRow;$start++){
//读取单元格
$temp['title']=$objPHPExcel->getActiveSheet()->getCell("B".$start)->getValue();
//物业编号,认证码为空 不要
if(empty($temp['title'])){
continue;
}
$temp['assess']=$objPHPExcel->getActiveSheet()->getCell("C".$start)->getValue();
$temp['is_status']=$objPHPExcel->getActiveSheet()->getCell("D".$start)->getValue();
$temp['sort']=$objPHPExcel->getActiveSheet()->getCell("E".$start)->getValue();
$temp['aid']=$_POST['aid'];
$coll=ord("F");
foreach($fresult as $key=>$one){
$temp['form_content'][$one['id']]=$objPHPExcel->getActiveSheet()->getCell(chr($coll).$start)->getValue();
$coll++;
}
$temp['form_content']=serialize($temp['form_content']);
if($objPHPExcel->getActiveSheet()->getCell("A".$start)->getValue()){
$temp['id']=$objPHPExcel->getActiveSheet()->getCell("A".$start)->getValue();
array_push($delete, $temp);
}else{
array_push($update, $temp);
}
unset($temp);
}
array(2) { [0]=> array(6) { ["title"]=> object(PHPExcel_RichText)#223 (1) { ["_richTextElements":"PHPExcel_RichText":private]=> array(2) { [0]=> object(PHPExcel_RichText_Run)#224 (2) { ["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#227 (12) { ["_name":protected]=> string(6) "瀹嬩綋" ["_size":protected]=> int(11) ["_bold":protected]=> bool(false) ["_italic":protected]=> bool(false) ["_superScript":protected]=> bool(false) ["_subScript":protected]=> bool(false) ["_underline":protected]=> string(4) "none" ["_strikethrough":protected]=> bool(false) ["_color":protected]=> object(PHPExcel_Style_Color)#228 (4) { ["_argb":protected]=> string(8) "FF000000" ["_parentPropertyName":protected]=> NULL ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL } ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL ["colorIndex"]=> int(8) } ["_text":"PHPExcel_RichText_TextElement":private]=> string(6) "椤烘櫙" } [1]=> object(PHPExcel_RichText_Run)#225 (2) { ["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#230 (12) { ["_name":protected]=> string(7) "Calibri" ["_size":protected]=> int(11) ["_bold":protected]=> bool(false) ["_italic":protected]=> bool(false) ["_superScript":protected]=> bool(false) ["_subScript":protected]=> bool(false) ["_underline":protected]=> string(4) "none" ["_strikethrough":protected]=> bool(false) ["_color":protected]=> object(PHPExcel_Style_Color)#231 (4) { ["_argb":protected]=> string(8) "FF000000" ["_parentPropertyName":protected]=> NULL ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL } ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL ["colorIndex"]=> int(8) } ["_text":"PHPExcel_RichText_TextElement":private]=> string(5) "1-502" } } } ["assess"]=> string(6) "宸蹭氦" ["is_status"]=> float(1) ["sort"]=> float(1000) ["aid"]=> string(3) "692" ["form_content"]=> string(32) "a:2:{i:829;d:123;i:830;d:42225;}" } [1]=> array(6) { ["title"]=> object(PHPExcel_RichText)#236 (1) { ["_richTextElements":"PHPExcel_RichText":private]=> array(2) { [0]=> object(PHPExcel_RichText_Run)#237 (2) { ["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#240 (12) { ["_name":protected]=> string(6) "瀹嬩綋" ["_size":protected]=> int(11) ["_bold":protected]=> bool(false) ["_italic":protected]=> bool(false) ["_superScript":protected]=> bool(false) ["_subScript":protected]=> bool(false) ["_underline":protected]=> string(4) "none" ["_strikethrough":protected]=> bool(false) ["_color":protected]=> object(PHPExcel_Style_Color)#241 (4) { ["_argb":protected]=> string(8) "FF000000" ["_parentPropertyName":protected]=> NULL ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL } ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL ["colorIndex"]=> int(8) } ["_text":"PHPExcel_RichText_TextElement":private]=> string(6) "椤烘櫙" } [1]=> object(PHPExcel_RichText_Run)#238 (2) { ["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#243 (12) { ["_name":protected]=> string(7) "Calibri" ["_size":protected]=> int(11) ["_bold":protected]=> bool(false) ["_italic":protected]=> bool(false) ["_superScript":protected]=> bool(false) ["_subScript":protected]=> bool(false) ["_underline":protected]=> string(4) "none" ["_strikethrough":protected]=> bool(false) ["_color":protected]=> object(PHPExcel_Style_Color)#244 (4) { ["_argb":protected]=> string(8) "FF000000" ["_parentPropertyName":protected]=> NULL ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL } ["_isSupervisor":protected]=> bool(false) ["_parent":protected]=> NULL ["colorIndex"]=> int(8) } ["_text":"PHPExcel_RichText_TextElement":private]=> string(5) "1-503" } } } ["assess"]=> string(6) "鏈浜" ["is_status"]=> float(1) ["sort"]=> float(1001) ["aid"]=> string(3) "692" ["form_content"]=> string(32) "a:2:{i:829;d:125;i:830;d:42225;}" } }