Adding Image to the Excel in phpexcel in php

后端 未结 3 1476
慢半拍i
慢半拍i 2020-12-29 23:26

I am taking the example from phpexcel

I just tried with passing value in GET Method, I am done with that.

Now i am trying to add image in the a3 coloumn.

<
相关标签:
3条回答
  • 2020-12-29 23:31

    Read my article,

    http://www.7codes.info/post/8/export-excel-files-with-images-using-php-excel-library

    $objDrawing = new PHPExcel_Worksheet_Drawing();    //create object for Worksheet drawing
    $objDrawing->setName('Customer Signature');        //set name to image
    $objDrawing->setDescription('Customer Signature'); //set description to image
    $signature = $reportdetails[$rowCount][$value];    //Path to signature .jpg file
    $objDrawing->setPath($signature);
    $objDrawing->setOffsetX(25);                       //setOffsetX works properly
    $objDrawing->setOffsetY(10);                       //setOffsetY works properly
    $objDrawing->setCoordinates($column.$cell);        //set image to cell
    $objDrawing->setWidth(32);                 //set width, height
    $objDrawing->setHeight(32);  
    
    $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());  //save
    
    0 讨论(0)
  • 2020-12-29 23:39

    I solve logo or images insert/showing problem use below code:

    $objDrawing = new PHPExcel_Worksheet_Drawing();
    $objDrawing->setName('test_img');
    $objDrawing->setDescription('test_img');
    $objDrawing->setPath('../images/logo.png');
    $objDrawing->setCoordinates('A1');                      
    //setOffsetX works properly
    $objDrawing->setOffsetX(5); 
    $objDrawing->setOffsetY(5);                
    //set width, height
    $objDrawing->setWidth(100); 
    $objDrawing->setHeight(35); 
    $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
    
    0 讨论(0)
  • 2020-12-29 23:52

    Specifying coordinates for the image might help, as per the examples and the documentation

    $objDrawing->setCoordinates('A3');
    

    Note that an image isn't in a cell/column/row, but overlaid over the main sheet at the same position as that cell/column/row

    0 讨论(0)
提交回复
热议问题