Reputation: 587
I have XLS cells deference number formatted. this how look like my cells
I want to read these above cells data without any changes(Friday, May 10, 2013 , 41404.00, drfsdf, 1/2) i use below method for that but i didn't success every bellow method return for text value of the cells
$objReader = new PHPExcel_Reader_Excel5();
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($file_path);
$rowIterator = $objPHPExcel->getActiveSheet()->getRowIterator();
$array_data = array();
foreach ($rowIterator as $row) {
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$rowIndex = $row->getRowIndex();
$array_data[$rowIndex] = array('A' => '', 'B' => '');
foreach ($cellIterator as $cell) {
if ('A' == $cell->getColumn()) {
$array_data[$rowIndex][$cell->getColumn()] = $cell->getCalculatedValue();
} else if ('B' == $cell->getColumn()) {
$array_data[$rowIndex][$cell->getColumn()] = $cell->getCalculatedValue();
}
}
}
please help to get view value of the XLS file as Friday, May 10, 2013 , 41404.00, drfsdf, 1/2
in to the $array_data using PHPExcel.
Upvotes: 0
Views: 2812
Reputation: 212402
Get rid of the
$objReader->setReadDataOnly(true);
otherwise PHPExcel has no way of knowing whether a cell is formatted as a date or not
setReadDataOnly(true) tells PHPExcel to load only the raw data from each cell. As the only way MS Excel differentiates a date/time from a float is through the number format mask (not from the raw data), and you're telling PHPExcel not to read the number format masks, PHPExcel can't tell the diference, so all floats are simply treated as floats
Upvotes: 2