我使用PHPExcel對我的代碼,我在這部分得到一個錯誤:參數1傳遞給PHPExcel_Shared_Date :: isDateTime()必須PHPExcel_Cell的一個實例,雙定
線159 -179:
if($extitle == $h){
$data = $objWorksheet->getCellByColumnAndRow($col, $row);
if(PHPExcel_Shared_Date::isDateTime($data)){
$cellValue = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
$dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue);
$dob = date('Y-m-d',$dateValue);
$tz = new DateTimeZone('Asia/Manila');
$rage = DateTime::createFromFormat('Y-m-d', $dob, $tz)->diff(new DateTime('now', $tz))->y;
}else{
$dob = "NULL";
}
}
線180 -185
if($extitle == $i){ $data = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); $mstatus = $data;
}
if($extitle == $j){ $data = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); $category = $data;
}
我得到的錯誤:Catchable fatal error: Argument 1 passed to PHPExcel_Shared_Date::isDateTime() must be an instance of PHPExcel_Cell, double given, called in *****\uploadexceldata.php on line 187 and defined in ******\Classes\PHPExcel\Shared\Date.php on line 254
if($extitle == $q){
$data = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
//in this part the error occured
if(PHPExcel_Shared_Date::isDateTime($data)){
$cellValue = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
$dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue);
$efdate = date('Y-m-d',$dateValue);
}else{
$efdate = "NULL";
}
}
但是,當我刪除行189其中if($extitle == $p){ $data = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
它工作正常。
現在,我想知道爲什麼發生這種情況,我該如何解決它。
謝謝先生,你總是救我時,即時通訊麻煩 – itsmecidz 2014-10-29 09:57:52