I have a system that takes an Excel file, does some manipulation and then exports to a CSV file ready for import into something else.
Everything works except the numbers; when the CSV file is import into the final system the numbers show up as 1E+11 for example.
I have a previous CSV file that works and the only difference I can see when I open it in Notepad is that there is a whitespace after the number e.g
123456643567 ,872871643567 ,465435654356
Whereas the new file doesn't have any whitespace after the number e.g
123456643567,872871643567,465435654356
This is the only difference I can see so can only presume this is causing the problem, however I don't know how to add that white space in. If I try and just append a whitespace to the end then the numbers are surrounded by speech marks and this still doesn't work e.g
"123456643567 ","872871643567 ","465435654356 "
Is there a way to add this in or is there something else at work causing this issue?
Edit:
For reference, below is the code I have to read in the Excel file using PHPExcel:
// Identify the type of $file
$file_type = PHPExcel_IOFactory::identify($file);
// Create a new Reader of the type that has been identified
$reader = PHPExcel_IOFactory::createReader($file_type);
// Load $file to a PHPExcel Object
$obj = $reader->load($file);
// Load file into rowIterator
$rows = $obj->getActiveSheet()->getRowIterator();
// Create array
$excel_array = array();
foreach($rows as $row){
$cells = $row->getCellIterator();
$index = $row->getRowIndex ();
// Check row contains data
if($index>=$req_array[$req][0]){
foreach ($cells as $cell) {
$column = $cell->getColumn();
// Check column is needed
if(strpos($req_array[$req][1],'|'.$column.'|')!==false){
$excel_array[$index][$column] = $cell->getCalculatedValue();
}
}
}
}
// Return array
return $excel_array;
The req_array just includes a string of required columns and the row to start on.