[英]PHPExcel: How to read time cells with miliseconds like they are displayed in excel
So my sports team (Swimming) asked me to make a small web app to read the times from swimmers and compare it to other swimmers because they knew I'm into programming, although I'm completely new to PHP and I have no clue what I am doing. 因此,我的运动团队(游泳)要求我制作一个小型Web应用程序,以从游泳者那里读取时间并将其与其他游泳者进行比较,因为他们知道我正在编程,尽管我是PHP的新手,我也不知道该怎么做。我在做。
Because the sport is swimming the times are pretty precise like: 0:22.13. 因为这项运动是游泳,所以时间非常精确,例如:0:22.13。
The 0 being minutes, 22 seconds and 13ms. 0为分钟,22秒和13ms。 I found ways to this if the cells contain Hours Minutes Seconds but not Minutes Seconds Milliseconds... 如果单元格包含时分秒,但不包含分秒毫秒,我发现了解决方法...
The code I have right now: 我现在拥有的代码:
if(isset($_POST['submit'])) {
$name = $_POST['user'];
$uid = -1;
$inputFileName = "tijden.xls";
$inputFileType = "Excel5";
$excel = PHPExcel_IOFactory::load('tijden.xls');
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$sheet = $excel->getActiveSheet()->toArray(null);
$login = false;
//echo json_encode($sheet);
for($i = 1; $i < sizeof($sheet); $i++) {
if($name == $sheet[$i][1]) {
$uid = $i;
$login = true;
$i = sizeof($sheet);
}
}
if($login) {
$data = $objPHPExcel->getActiveSheet()->getCell('K'.$uid)->getCalculatedValue();
echo($data);
echo("\n");
}
}
?>
And what it outputs is 0.0014407407407407 它输出的是0.0014407407407407
So, in short, I want to make PHPExcel read the time cells in a way so the time is displayed properly... 因此,简而言之,我想使PHPExcel以某种方式读取时间单元,以便正确显示时间...
Have a look at this: http://www.osakac.ac.jp/labs/koeda/tmp/phpexcel/Documentation/API/PHPExcel_Style/PHPExcel_Style_NumberFormat.html 看看这个: http : //www.osakac.ac.jp/labs/koeda/tmp/phpexcel/Documentation/API/PHPExcel_Style/PHPExcel_Style_NumberFormat.html
setFormatCode should have a method to get the exact format that you want. setFormatCode应该有一个方法来获取所需的确切格式。
This might also be relevant: PHPExcel String to Time 这可能也相关: PHPExcel时间字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.