我爱编程

PHP导出Excel插入图片

2018-04-08  本文已影响0人  dongshixiao

参考:
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');
上一篇下一篇

猜你喜欢

热点阅读