I'm using PHPExcel library to loop through my excel spreadsheet. This is my current script :
try
{
$inputfiletype = PHPExcel_IOFactory::identify($inputfilename);
$objReader = PHPExcel_IOFactory::createReader($inputfiletype);
$objPHPExcel = $objReader->load($inputfilename);
$r = array( 'd' => true );
}
catch(Exception $e)
{
die('Error loading file "'.pathinfo($inputfilename,PATHINFO_BASENAME).'": '.$e->getMessage());
$r = array( 'd' => false );
}
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// 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);
echo $rowData[0][0] . '</br>';
}
This is my spreadsheet :
What I'm trying to do is loop through each row, ignore the nulls and produce an object with the column name. For the example in the above image row 5 would produce :
{HVHV001OXLG:{
A5AR:"152",
A5AM:"988",
A5AL:"100"
}
}
Is it possible to produce something like this from the format of my spreadsheet?