load($_FILES['file']['tmp_name']);
//$lastRow = $spreadsheet->getHighestDataRow();
//echo $lastRow;
$worksheet = $spreadsheet->getActiveSheet();
// Get the highest row and column numbers referenced in the worksheet
$highestRow = $worksheet->getHighestRow(); // e.g. 10
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'//$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); // e.g. 5
echo 'hrow='.$highestRow.' hcol'.$highestColumn ;
$col='K';
$row=6;
echo '
' .
$worksheet->getCell($col . $row)
->getValue() .
' | ' . PHP_EOL;
$cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(1, 4)->getCalculatedValue();
echo $cellValue;
$cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(6, 5)->getValue();
echo $cellValue;
$cellValue = $spreadsheet->getActiveSheet()->getCell('A11')->getValue();
$nn=1;
echo 'my cell value='.$cellValue.'===';
$sheetData = $spreadsheet->getActiveSheet()->toArray();
if (!empty($sheetData)) {
for ($i=1; $iquery($sql);
if (!$result) {
echo $brn. " not ror, could not list tables\n";
//exit;
}
$brid=0;
while($row = $result->fetch_assoc()) {
$brid=$row["branch_id"];
}
$dgid=0;
$sql="select * from designation where desig='".$dg."'";
echo $sql;
$result = $conn->query($sql);
if (!$result) {
echo $dg. " not ror, could not list tables\n";
//exit;
}
while($row = $result->fetch_assoc()) {
$dgid=$row["id"];
}
echo "brid=".$brid."==";
echo "desg=".$dgid."==";
$sql1="insert into budget_manpower_table ( company_id,branch_id,desig_id,budget_head_count,budget_shifts,budget_id ) values ( 119,".$brid.",".$dgid.",".$hc.",".$sc.",".nn.")";
if (mysqli_query($conn, $sql1)) {
// echo "New record created successfully";
//} else {
// echo "Error: " . $sql . "
" . mysqli_error($conn);
}
$nn++;
// $db->query("INSERT INTO USERS(name, email, company) VALUES('$name', '$email', '$company')");
}
}
echo "Records inserted successfully.";
} else {
echo "Upload only CSV or Excel file.";
}
}
?>