PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

Shared\Date::isDateTime() fails

Open madorin opened this issue 2 years ago • 1 comments

This is:

- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Shared\Date::isDateTime() should return true

What is the current behavior?

Shared\Date::isDateTime() returns false

What are the steps to reproduce?

@MarkBaker ,

Since https://github.com/PHPOffice/PhpSpreadsheet/commit/432e5845e1c016699a847bcbc3e8106b1872c75f commit was merged some date type cells are reported as non-date type.

Not sure what was the reason to add the is_numeric( check but it broke the functionality, at least in my case.

image

In actual code, $cell->getCalculatedValue() returns a string and is_numeric() check is not passed.

madorin avatar May 05 '23 08:05 madorin

In my case Shared\Date::isDateTime() doesn't return true on a date cell even when I comment out the is_numeric() condition because $activeSheet->getStyle($cell->getCoordinate())->getNumberFormat()->getFormatCode() returns "General" for some reason even though when I open the file in excel the cell value is correctly formatted to a date. $cell->getValue() returns int 45108

[edit] my bad, I forgot I was setting $reader->setReadDataOnly(TRUE)

lukemim avatar Jul 10 '23 10:07 lukemim