I'm trying to read some data from excel file. Everything is good if i have ex.50.44% in my excel cell PHP excel format it like float 0.0531 i dont want to format any numbers and i want all cell to be casted as string. How can i accomplish this before making the data toArray();
Here my sample code
try {
$objPHPExcel = PHPExcel_IOFactory::load($upload_url);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($upload_url,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$objPHPExcel->getDefaultStyle()
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
var_dump($sheetData);
exit;
If you simply want all values as strings rather than the appropriate datatype, then retrieve your array as you're doing at the moment, then execute:
array_walk_recursive(
$sheetData,
function (&$value) {
$value = (string) $value;
}
);