phpexcel 读取日期问题
发布网友
发布时间:2022-04-21 23:26
我来回答
共1个回答
热心网友
时间:2024-08-14 12:04
Vendor('PHPExcel.PHPExcel.IOFactory');
$inputFileName = 'Public/demo/demo.xls';
$objReader = new PHPExcel_Reader_Excel5();
$objPHPExcel = $objReader->load($inputFileName);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
$tempArray = array();
for($j=2;$j<=$highestRow;$j++){
for($k='A';$k<=$highestColumn;$k++){
if($k=='H'){//指定H列为时间所在列
$tempArray[] = gmdate("Y-m-d H:i:s", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue()));
}else{
$tempArray[] = $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue();
}
echo "<pre>";
print_r($tempArray);
unset($tempArray);
echo "</pre>";
}
}