Adding a logo to an excel sheet using php excel

后端 未结 3 936
清酒与你
清酒与你 2021-01-05 15:55

I am trying to add a logo image on a generated excel worksheet using the code listing below but for some reason it does nothing

    $objReader = PHPExcel_IO         


        
3条回答
  •  鱼传尺愫
    2021-01-05 16:31

    Adding logo is so simple, try below code.

    $objPHPExcel = new PHPExcel();
    $sheet = $objPHPExcel->setSheetIndexAndTitle(1, "YOUR_SHEET_TITLE"); // first sheet
    $objDrawing = new PHPExcel_Worksheet_Drawing();
    $objDrawing->setName('Logo');
    $objDrawing->setDescription('Logo');
    $logo = base_path() . '/images/logo.png'; // Provide path to your logo file
    $objDrawing->setPath($logo);
    $objDrawing->setOffsetX(8);    // setOffsetX works properly
    $objDrawing->setOffsetY(300);  //setOffsetY has no effect
    $objDrawing->setCoordinates('B1');
    $objDrawing->setHeight(75); // logo height
    $objDrawing->setWorksheet($sheet); 
    

提交回复
热议问题