How to export images in PHPEXCEL?

Source: Internet
Author: User
If you want to export an image in PHPEXCEL, you can use phpexcel to export an excel file. However, you need to export an image at the same time. How can I implement the code? I am very grateful to you for your reference!


Reply to discussion (solution)

Phpexcel is a very powerful class, it should be OK. Read the document.

Read the usage of the PHPExcel_Worksheet_Drawing class.

Can I post the source code? a lot of points

$p = new PHPExcel();$p->getActiveSheet()->setCellValue('D8', 'Image');$d = new PHPExcel_Worksheet_Drawing();$d->setPath('03.gif');$d->setCoordinates('D10');$d->setWorksheet($p->getActiveSheet());$t = PHPExcel_IOFactory::createWriter($p, 'Excel5');$t->save('tu.xls');

Phpexcel is a very powerful class, it should be OK. Read the document. It is recommended that there are many examples on the Internet.

PHP code
$ P = new PHPExcel ();
$ P-> getActiveSheet ()-> setCellValue ('d8', 'image ');

$ D = new PHPExcel_Worksheet_Drawing ();
$ D-> setPath('03.gif ');
$ D-> setCoordinates ('d10 ');
$ D-> setWorksheet ($ p-> getAct ......

Learn how to export images!

PHP code
$ P = new PHPExcel ();
$ P-> getActiveSheet ()-> setCellValue ('d8', 'image ');

$ D = new PHPExcel_Worksheet_Drawing ();
$ D-> setPath('03.gif ');
$ D-> setCoordinates ('d10 ');
$ D-> setWorksheet ($ p-> getAct ...... I used to export images, but I haven't seen any mistakes.

The image must be a "local" image like this http://17zencart.com/data/attachment/forum/201210/13/135720yffmf02fbd202fsf.png such images seem to be unable to import my approach is to first use the image downloaded to the local and then added to the excel inside do not know whether there is another more convenient method is how to center images on top of my images.

$ ObjDrawing = new PHPExcel_Worksheet_Drawing ();
$ ObjDrawing-> setName ('photo ');
$ ObjDrawing-> setDescription ('image inserted by pyxjm ');

$ Imgpath = "your image address absolute path"
$ ObjDrawing-> setPath ($ imgpath );
$ ObjDrawing-> setWidth ('25pt ');
$ ObjDrawing-> setHeight ('20pt ');

$ ObjDrawing-> setOffsetX (2 );
$ ObjDrawing-> getShadow ()-> setVisible (true );
$ ObjDrawing-> setCoordinates ($ array [$ k]. $ d );
// $ ObjDrawing-> setMimeType (PHPExcel_Worksheet_MemoryDrawing: MIMETYPE_DEFAULT );
$ ObjDrawing-> setWorksheet ($ objExcel-> getActiveSheet ());

This is the code for exporting an English path image in phpexcel, but it cannot be used in Chinese. Currently, the solution is in progress.-If you solve this problem first, please let me know --

PHP code? 12345678910 $ p = new PHPExcel (); $ p-> getActiveSheet ()-> setCellValue ('d8', 'image'); $ d = new PHPExcel_Worksheet_Drawing (); $ d-> setPath('03.gif '); $ d-> setCoordinates ('d10'); $ d-> setWor ......
The moderator is really good, tested and easy to use!

Why is an error reported when I add images to the loop? How to export multiple images?

The image must be a "local" image like this http://17zencart.com/data/attachment/forum/201210/13/135720yffmf02fbd202fsf.png such images seem to be unable to import my approach is to first use the image downloaded to the local and then added to the excel inside do not know whether there is another more convenient method is how to center images on top of my images.


It seems that this is the only option ~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.