'How to embed a pdf file in an excel worksheet using phpspreadsheet?

How to embed a pdf file in an excel worksheet using phpspreadsheet?

        $file= 'kl.pdf';
        
        $objDrawing = new PHPExcel_Worksheet_Drawing();
         $objDrawing->setPath('./assets/tpaudit/checkpoint_ng_image/'.$file);
                $objDrawing->setCoordinates('H2');
                    
            $objDrawing->setWidth(120);    
                    $objDrawing->setHeight(120);  
                $objDrawing->setWorksheet($this->excel->getActiveSheet());
               
                $objDrawing->setOffsetX(5);
                $objDrawing->setOffsetY(5);
            
            $this->excel->getActiveSheet()->getRowDimension(2)->setRowHeight(150);  

        $this->excel->getActiveSheet()->getStyle('H2')->applyFromArray(
            array( 
                    'borders' => array (
                    'allborders' => array (
                        'style' => PHPExcel_Style_Border::BORDER_THIN  ,
                            'color' => array('rgb' => '000000'),        // BLACK
                        )
                    )
                )
        );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source