Phpexcel read the pictures in Excel and save them to the local method _php tips

Source: Internet
Author: User

Hpexcel is a fairly powerful MS Office Excel document Generation Class library, and Phpexcel is a good choice when it comes to outputting more complex format data.

After careful study of the API documentation and viewing the official documents, I finally found the picture in Excel, which I can only read in Excel 2003 format. Excel2007 doesn't seem to support it. The main API used is phpexcel_worksheet,phpexcel_worksheet_basedrawing,phpexcel_worksheet_memorydrawing.

Less nonsense, directly on the code:

Copy Code code as follows:

Require_once './classes/phpexcel.php ';
$objPHPExcel = new Phpexcel ();
$objReader = Phpexcel_iofactory::createreader (' Excel5 '); Load 2003 of
$objPHPExcel = $objReader->load ("Goods_list.xls"); Loading files
foreach ($objPHPExcel->getsheet (0)->getdrawingcollection () as $k => $drawing) {
$codata = $drawing->getcoordinates (); Get the cell data, like the G2 unit.
$filename = $drawing->getindexedfilename (); Filename
Ob_start ();
Call_user_func (
$drawing->getrenderingfunction (),
$drawing->getimageresource ()
);
$imageContents = Ob_get_contents ();
File_put_contents (' pic/'. $codata. _ '. $filename. '. JPG ', $imageContents); Save the file to the local
Ob_end_clean ();
}

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.