PHP导出Excel插入图片

参考:
http://www.maatwebsite.nl/laravel-excel/docs
首先 引入
use Maatwebsite\Excel\Facades\Excel;

//逻辑

set_time_limit(0);

Excel::load('./1.xlsx', function ($reader) {
            $sheet = $reader->getExcel()->getActiveSheet();
            $sheet->setCellValue('H42', 'OKKKK');
            //添加图片
            $objDrawing = new \PHPExcel_Worksheet_Drawing();
            $signature = './img/banner1.jpg';//路片路径
            $objDrawing->setPath($signature);
            $objDrawing->setCoordinates('E' . '42');//坐标
            $objDrawing->setWidth(160);//图片宽
            $objDrawing->setHeight(100);//图片高
            $objDrawing->setWorksheet($reader->getActiveSheet());
        })->export('xls');

你可能感兴趣的:(PHP导出Excel插入图片)