Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set correct reading format for a cell with PHPExcel

Tags:

php

phpexcel

I'm using PHPExcel to read an Excel 2007 document. In this document there's a column with "Time" formatting and it displays data correctly in Excel. When I try to parse this column I get some weird values. Any idea how can I fix this?

Thank you.

like image 918
Psyche Avatar asked Nov 21 '25 17:11

Psyche


1 Answers

When parsing, you need to specify the format of the column. e.g.

$my_cell = $objWorksheet->getCellByColumnAndRow(1, 1);
$my_cell_value = PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), 'hh:mm:ss');
print $my_cell_value;
like image 93
james_tookey Avatar answered Nov 23 '25 09:11

james_tookey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!