I have a problem regarding PHPExcel when reading .csv files.
I wanted to get the values from the .csv file, but the problem is the data from a specific row considered as a single cell.
heres my code:
include 'Classes/PHPExcel/IOFactory.php';
$inputFileType = 'CSV';
$inputFileName = $_FILES['file']['tmp_name'];
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$table = "<table border=1><tr><td>first</td><td>middle</td><td>last</td><td>email</td>";
for ($x = 2; $x <= count($sheetData); $x++){
foreach ($sheetData[$x] as $data){
$first = $sheetData[$x]['A'];
$middle = $sheetData[$x]['B'];
$last = $sheetData[$x]['C'];
$email = $sheetData[$x]['D'];
}
$table .= "<tr><td>" . $first ."</td><td>" . $middle . "</td><td>" . $last . "</td><td>" . $email . "</td></tr>";
}
$table .= "</table>";
echo $table;
It is working on .xls and .xlsx files and I get the desired output that I wanted.