code sample
require_once 'excel/PHPExcel.php';
require_once 'excel/PHPExcel/Cell/AdvancedValueBinder.php';
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '12/08/2010')
->setCellValue('A2', '14/12/2013');
Why is that that value binder doesn’t recognize that it’s a date? Therefore Excel handles the data as string so no sorting 🙁
This problem related to the PHPExcel_Shared_Date::stringToExcel() method failing to recognise strings containing / as potentially being valid dates…. an issue that was resolved in version 1.7.5.
The default date format mask for the AdvancedValueBinder is ‘yyyy-mm-dd’. You’re not limited to the formats listed in PHPExcel_Style_NumberFormat; but you can then set the format to anything that is accepted by Excel. so: