I have following code for reading data from .xls file.
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(false);
$objPHPExcel = $objReader->load($inputFileName);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$chunksize=_CHUNKSIZE_;
$endRow=$chunksize;
$count=ceil($highestRow/$chunksize);
for ($row=1;$row<=$endRow;$row++)
{
if($row>$highestRow){
break;
}
for ($col=0;$col<$highestColumnIndex;$col++)
{
$cellobj=$objWorksheet->getCellByColumnAndRow($col, $row);
$value=$cellobj->getValue();
if(PHPExcel_Shared_Date::isDateTime($cellobj)) { //to check the date
$value=$cellobj->getFormattedValue();
}
}
}
Here it returns the date in 'mm-dd-yyyy' format when in any date is provided in any format. I actually need to validate that the date should be in the 'dd-mm-yyyy'.
</div>