Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.145.115.45
<?php
/*$servername = "localhost";
$username = 'root';
$password = "";
$databse = 'cuk_convo';*/
ini_set('display_errors', 1);
require_once(__DIR__ . "/../../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
$username = 'admin';
$password = "Logisys2104";
$databse = 'logisys3_sikkim';
$conn = new mysqli($servername,$username,$password,$databse);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
include('PHPExcel-1.8/Classes/PHPExcel.php');
include('PHPExcel-1.8/Classes/PHPExcel/Writer/Excel2007.php');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("PHPExcel Test Document")
->setSubject("PHPExcel Test Document")
->setDescription("Test document for PHPExcel, generated using PHP classes.")
->setKeywords("office PHPExcel php")
->setCategory("Test result file");
$collcode_query = "SELECT fappno,
fphotopath,
fdegree as degree,
fname as department,
fcollcode as School
FROM studadm dc where fsex = 'n' limit 1";
$result = mysqli_query($conn,$collcode_query);
$i=0;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValueByColumnAndRow(0,1,'Sl. No.')
->setCellValueByColumnAndRow(1,1,'Enroll No.')
->setCellValueByColumnAndRow(2,1,'Degree')
->setCellValueByColumnAndRow(3,1,'Department')
->setCellValueByColumnAndRow(4,1,'School')
->setCellValueByColumnAndRow(5,1,'Photo');
//$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(100);
$i = 2;
$full_photo_path="";
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
)
);
while($coll = mysqli_fetch_array($result,MYSQLI_NUM))
{
$keyname = '018/'.$coll[1];
$objPHPExcel->setActiveSheetIndex(0)
->setCellValueByColumnAndRow(0,$i,$i)
->setCellValueByColumnAndRow(1,$i,$coll[0])
->setCellValueByColumnAndRow(2,$i,$coll[2])
->setCellValueByColumnAndRow(3,$i,$coll[3])
->setCellValueByColumnAndRow(4,$i,$coll[4]);
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(110);
if($keyname != ''){
$keyname = '/018/'.$coll[1];
$ext = pathinfo($coll[1], PATHINFO_EXTENSION);
$filePath = tempnam(sys_get_temp_dir(), rand(10,15));
rename($filePath, $filePath .= ".".$ext);
$filePath = $filePath;
try{
$result = $s3->getObject([
'Bucket' => STUDENT_PHOTOS_BUCKET,
'Key' => $keyname,
'SaveAs' => $filePath
]);
}
catch(S3Exception $e){
}
$n = 'F'.$i;
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('test_img');
$objDrawing->setDescription('test_img');
//$objDrawing->setPath("https://university-student-photos.s3.ap-south-1.amazonaws.com/018/".$coll[1]);
$objDrawing->setPath($filePath);
$objDrawing->setCoordinates($n);
$objDrawing->setHeight(138);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
}
$i++;
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="sikkim_adm.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
?>
|