$inputFileName = 'upload/'.$_POST['filename'];
// Read your Excel workbook
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
} catch (Exception $e) {
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME)
. '": ' . $e->getMessage());
}
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$str = '';
// Loop through each row of the worksheet in turn
for ($row = 1; $row <= $highestRow; $row++) {
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,
NULL, TRUE, FALSE);
$even = $row%2==0? "class='even'":"";
$str .= '';
foreach($rowData[0] as $k=>$v){
//echo "Row: ".$row."- Col: ".($k+1)." = ".$v."
";
//$data[$row][$k+1][] = $v;
if($row == 1){
$str .= ''.$v.' ';
} else {
$str .= ''.$v.' ';
}
}
$str .= ' ';
}
$str .= '
';
echo $str;
}