PHPExcel: how to read an image from an EXCEL file and save it to a local file. _ PHP Tutorial

Source: Internet
Author: User
PHPExcel reads an image in EXCEL and saves it to a local device ,. PHPExcel is a very powerful class library for generating MSOfficeExcel documents. when you need to output complex format data, PHPE PHPExcel: how to read an image from an EXCEL file and save it to a local file,

HPExcel is a very powerful MS Office Excel file generation class library, when you need to output more complex format data, PHPExcel is a good choice.

After carefully studying the API documentation and viewing official documentation, I finally found the image in EXCEL. Currently, I can only read the image in excel 2003 format. Excel2007 does not seem to be supported yet. The main APIs are PHPExcel_Worksheet, PHPExcel_Worksheet_BaseDrawing, and PHPExcel_Worksheet_MemoryDrawing.

Put the following code directly:

The code is as follows:


Require_once './Classes/PHPExcel. php ';
$ ObjPHPExcel = new PHPExcel ();
$ ObjReader = PHPExcel_IOFactory: createReader ('excel5'); // load the 2003
$ ObjPHPExcel = $ objReader-> load ("goods_list.xls"); // load the file
Foreach ($ objPHPExcel-> getSheet (0)-> getDrawingCollection () as $ k => $ drawing ){
$ Codata = $ drawing-> getCoordinates (); // Obtain the unit data, such as the G2 unit.
$ Filename = $ drawing-> getIndexedFilename (); // file name
Ob_start ();
Call_user_func (
$ Drawing-> getRenderingFunction (),
$ Drawing-> getImageResource ()
);
$ ImageContents = ob_get_contents ();
File_put_contents ('Pic/'.w.codata.'_'.w.filename.'.jpg ', $ imageContents); // Save the file to your local device.
Ob_end_clean ();
}

Sheet, HPExcel is quite powerful MS Office Excel document generation class library, when you need to output more complex format data, PHPE...

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.