I`m trying to make a simple page in php where data from an excel sheet is displayed.
I have gone through this link.
when I use foreach loop to print the values of $rowData I get only one value printed. My Excel Document consists of 2 Columns Attendance and register number only the first value is displayed.
here`s teh foreach am using
foreach($rowData as $row){
foreach($row as $var){
echo "{$var}<br/>";
}
}
I searched for information regarding rangeToArray method but am not able to get information regarding what parameters are passed to it.Please can someone explain how the method works..
Edit: output when print_r used
Array (
[0] => Array (
[0] => Register Number
[1] => Attendance
)
)
Array (
[0] => Array (
[0] => UR11CS012
[1] => 0.78
)
)
Array (
[0] => Array (
[0] => UR11CS013
[1] => 0.65
)
) Array (
[0] => Array (
[0] => UR11CS015
[1] => 0.67
)
)
Edit: here is the code still printing last value only whats wrong ? should i have saved file in a seaprate folder uploaded file rather than use it from the temporary folder
<?php
$name=$_FILES['u_file']['tmp_name'];
try {
$inputFileType = PHPExcel_IOFactory::identify($name);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($name);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
for ($row = 1; $row <= $highestRow; $row++){
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,NULL,TRUE,FALSE);
}
print_r($rowData);
?>