I don't know if this is the right approach, but what I did is tweaked a little bit on the rangeToArray() function:
publicfunction rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {// Returnvalue $returnValue = array();// Identify the range that we need to extract from the worksheetlist($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); $minCol = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] -1); $minRow = $rangeStart[1]; $maxCol = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] -1); $maxRow = $rangeEnd[1]; $maxCol++; // Loop through rows $r = -1;for ($row = $minRow; $row <= $maxRow; ++$row) { $rRef = ($returnCellRef) ? $row : ++$r; $c = -1;// Loop through columns in the current rowfor ($col = $minCol; $col != $maxCol; ++$col) { $cRef = ($returnCellRef) ? $col : ++$c;// Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen// so we test and retrieve directly against _cellCollectionif ($this->_cellCollection->isDataSet($col.$row)) {// Cell exists $cell = $this->_cellCollection->getCacheData($col.$row);// if ($cell->getValue() !== null) {if ($cell->getFormattedValue() !== null) {// if ($cell->getValue() instanceof PHPExcel_RichText) {if ($cell->getFormattedValue() instanceof PHPExcel_RichText) {// $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); $returnValue[$rRef][$cRef] = $cell->getFormattedValue()->getPlainText(); } else {if ($calculateFormulas) { $returnValue[$rRef][$cRef] = $cell->getCalculatedValue(); } else {// $returnValue[$rRef][$cRef] = $cell->getValue(); $returnValue[$rRef][$cRef] = $cell->getFormattedValue(); } }if ($formatData) { $style = $this->_parent->getCellXfByIndex($cell->getXfIndex());/* Here is the line I changed */if(PHPExcel_Shared_Date::isDateTime($cell)) { $returnValue[$rRef][$cRef] = date('Y-m-d', strtotime($returnValue[$rRef][$cRef])); }else{ $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode()); }/* End */ } } else {// Cell holds a NULL $returnValue[$rRef][$cRef] = $nullValue; } } else {// Cell doesn't exist $returnValue[$rRef][$cRef] = $nullValue; } } }//print_r($returnValue);// Returnreturn $returnValue; }
Hope this would help others.