<?php 
session_start();
error_reporting(E_ERROR | E_PARSE);
require '../Classes/PHPExcel.php';

$gdImage = imagecreatefrompng('../qr/temp/test.png');

if($_FILES["excel_file"]["error"] == 0)
{
    $irn = $_POST['irn_value'];
    $target_dir = "uploads/";
    $file = $_FILES['excel_file'];  
    $info = pathinfo($_FILES['excel_file']['name']);
    $ext = $info['extension']; // get the extension of the file
    $newname = "sample_247DC.".$ext; 
    $target = '../uploads/'.$newname;
    if(move_uploaded_file($_FILES["excel_file"]["tmp_name"], $target)){        
        $excel = PHPExcel_IOFactory::load($target);
        $excel ->setActiveSheetIndex(0);        
        $excel->getActiveSheet()->setCellValue('B22','IRN');
        $excel->getActiveSheet()->setCellValue('C22',$irn);
        $objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
        $objDrawing->setName('QR image');
        $objDrawing->setDescription('QR Details');
        $objDrawing->setImageResource($gdImage);

        $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
        $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
        $objDrawing->setHeight(250);
        $objDrawing->setCoordinates('I3');
        $objDrawing->setOffsetY(5);
        $objDrawing->setWorksheet($excel->getActiveSheet());
        $objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
        $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
    }
}
else{
    echo "false";
}
?>