How PHPExcel reads pictures in EXCEL and saves them locally,
HPExcel is a very powerful MS Office Excel document generation library. When you need to output data in a more complex format, PHPExcel is a good choice.
After carefully studying the API documentation and checking the official documentation, I finally found how to read pictures in EXCEL. Currently, I can only read excel 2003 format. It seems that excel2007 does not support it yet. The main APIs used are PHPExcel_Worksheet, PHPExcel_Worksheet_BaseDrawing, PHPExcel_Worksheet_MemoryDrawing.
Stop talking nonsense and go straight to the code:
Copy code The code is as follows:
require_once './Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel5'); //Load 2003
$objPHPExcel = $objReader->load("goods_list.xls"); //Load file
foreach ($objPHPExcel->getSheet(0)->getDrawingCollection() as $k => $drawing) {
$codata = $drawing->getCoordinates(); //Get unit data, such as G2 unit
$filename = $drawing->getIndexedFilename(); //File name
ob_start();
call_user_func(
$drawing->getRenderingFunction(),
$drawing->getImageResource()
);
$imageContents = ob_get_contents();
file_put_contents('pic/'.$codata.'_'.$filename.'.jpg',$imageContents); //Save the file locally
ob_end_clean();
}
http://www.bkjia.com/PHPjc/958722.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/958722.htmlTechArticlePHPExcel reads pictures in EXCEL and saves them locally. HPExcel is a very powerful MS Office Excel document generation Class library, when you need to output data in more complex formats, PHPE...