How to Insert Image in Cell

Jun 29, 2013 at 11:10 AM
Edited Jun 29, 2013 at 12:02 PM
Hello sir,

I had done bellow code for inserting image in excel..
      $objDrawing = new PHPExcel_Worksheet_Drawing();
      $objDrawing->setWorksheet($objWorksheet);
      $objDrawing->setName("name");
      $objDrawing->setDescription("Description");
      $objDrawing->setPath('./path_to/image.png');
      $objDrawing->setCoordinates('B1');
      $objDrawing->setOffsetX(1);
      $objDrawing->setOffsetY(5);

__Its not working... but i use bellow code than it will working __________________________________

$gdImage = imagecreatefrompng('images/MM_Logo.png');
        $objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
        $objDrawing->setName('Sample image');
        $objDrawing->setDescription('Sample image');
        $objDrawing->setImageResource($gdImage);
        $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
        $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
        $objDrawing->setCoordinates('A1');
        $objDrawing->setWidth(300);
        $objDrawing->setHeight(38);

        $objPHPExcel->getActiveSheet()->setCellValue('A1', '                  ');
        $objPHPExcel->getActiveSheet()->getCell('A1')->getHyperlink()->setUrl('http://www.google.com');
        $objPHPExcel->getActiveSheet()->getCell('A1')->getHyperlink()->setTooltip('Navigate to website');
        $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

I want to insert image without gd library than how its possible??
Jul 1, 2013 at 3:59 PM
The first method works for me... Defined path is correct ?