Phpexcel read a picture in Excel and save it to a local method, _php tutorial

Source: Internet
Author: User

Phpexcel read the pictures in Excel and save them to a local method,


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

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

Say less nonsense, directly on the code:

Copy the 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 unit data like 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 a local
Ob_end_clean ();
}

http://www.bkjia.com/PHPjc/958722.html www.bkjia.com true http://www.bkjia.com/PHPjc/958722.html techarticle Phpexcel Read the pictures in Excel and save to the local method, Hpexcel is quite powerful in MS Office Excel document Generation Class library, when the 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.