query($sql); while($rowa = $resulta->fetch_assoc()) { $mxdt=$rowa["mxdt"]; // echo "mxdate".$mxdt; } $query = "select * from daily_frame_details where company_id=".$cmp." and doff_date='".$mxdt."' order by frame_no"; //echo $query; $result = $connect->query($query); $active_sheet = $file->getActiveSheet(); // $file->getActiveSheet()->getColumnDimension('A')->setWidth(10); // $file->getActiveSheet()->getColumnDimension('B')->setWidth(40); $active_sheet->setCellValue('A1', 'Last Upload Date '); $active_sheet->setCellValue('b1', 'Frame No'); $active_sheet->setCellValue('c1', 'Speed '); $active_sheet->setCellValue('d1', 'Kgs/Spindle '); $stdat=date('d-m-Y'); $count = 2; // foreach($result as $row) while($row = $result->fetch_assoc()) { $active_sheet->setCellValue('A' . $count, $mxdt); $active_sheet->setCellValue('B' . $count, $row["frame_no"]); $active_sheet->setCellValue('C' . $count, $row["frame_speed"]); $active_sheet->setCellValue('D' . $count, $row["kgs_spindle"]); $count = $count + 1; } //for ($i = 'A'; $i != $file->getActiveSheet()->getHighestColumn(); $i++) { $file->getActiveSheet()->getColumnDimension('A')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('B')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('C')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('D')->setAutoSize(TRUE); //} //$sheet->getProtection()->setSheet(true); $c=$count-1; $file->getActiveSheet()->getProtection()->setSheet(true); $file->getDefaultStyle()->getProtection()->setLocked(false); $active_sheet->getStyle('A1:A'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('B1:B'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($file, $_POST["file_type"]); $file_name = 'Daily_frame_data_'.$stdat.'.' . strtolower($_POST["file_type"]); $writer->save($file_name); header('Content-Type: application/x-www-form-urlencoded'); header('Content-Transfer-Encoding: Binary'); header("Content-disposition: attachment; filename=\"".$file_name."\""); readfile($file_name); unlink($file_name); exit; } else $_SESSION["favanimal"]=2; $cmp=2; $query = "SELECT concat(group_code,item_code) itemcode,item_desc,uom_code,location FROM itemmaster where op_2018=1 and company_id=$cmp order by group_code,item_code"; //$statement = $connect->prepare($query); //$statement->execute(); //$result = $statement->fetchAll(); //$result = $connect->query($query); if(isset($_POST["upload"])) { // $dtt= //echo "uploading 111"; $dtt=$_POST["date1"]; if (strlen($dtt)==0) { // exit; } $file_mimes = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); //echo "uploading 112"; // if(isset($_FILES['file']['name']) && in_array($_FILES['file']['type'], $file_mimes)) { $arr_file = explode('.', $_FILES['file']['name']); $extension = end($arr_file); $file_type="Xlsx"; if('csv' == $extension) { $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); } else { $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); } $spreadsheet1 = $reader->load($_FILES['file']['tmp_name']); $worksheet = $spreadsheet1->getActiveSheet(2); $sheetData = $spreadsheet1->getActiveSheet()->toArray(); //echo "uploading"; //} //$query = "SELECT concat(group_code,item_code) itemcode,item_desc,uom_code,location FROM itemmaster where group_code='116' order by group_code,item_code"; //op_2018=1 and company_id=$cmp order by group_code,item_code"; //$statement = $connect->prepare($query); //$statement->execute(); //$result = $statement->fetchAll(); //$result = $connect->query($query); } ?>