error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$inputFileName ="../brief/phaseupload/" . $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();
// Loop through each row of the worksheet in turn
for ($row = 3; $row <= $highestRow; $row++){
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
print_r($rowData);
I use above code to read the excel file using PHPExcel. I managed to read the excel value and print it. Now the problem is I need to store the values in the database. How do I get the value, in this case from $rowData?
Below is the sample output:
Array ( [0] => Array ( [0] => 854273_19 [1] => Beds [2] => 61 [3] => Autumn Winter 2012 [4] => Divans [5] => Fabric [6] => Storage Bedding [7] => Single Divan [8] => Not Required [9] => Fabric [10] => White [11] => Not Required [12] => Not Required [13] => [14] => Not Required [15] => Divan With Mattress [16] => Not Required [17] => Not Required [18] => Not Required ) ) 0