Use PhpExcel to read files in Excel

Source: Internet
Author: User
? Phpini_set (display_errors, 1); ini_set (include_path, ini_get (include_path).; F: sourcesPHPExcel_1.7.8-with_documentation-msoffice_formatClasses); set this page to contain paths includePHPExcel. php; includePHPExcelIOFactory. php; defin

? Phpini_set ("display_errors", 1); ini_set ('include _ path', ini_get ('include _ path '). '; F: // sources // PHPExcel_1.7.8-with_documentation-msoffice_format // Classes //'); // set this page to include the path 'phpexcel. php'; include 'phpexcel/IOFactory. php'; defin

 Load ($ fileName); $ worksheet = $ PHPExcel-> getActiveSheet (); $ imageInfo = extractImageFromWorksheet ($ worksheet, "f: //"); print_r ($ imageInfo ); function getExtendFileName ($ file_name) {$ extend = pathinfo ($ file_name); $ extend = strtolower ($ extend ["extension"]); return $ extend ;} function extractImageFromWorksheet ($ worksheet, $ basePath) {$ result = array (); $ imageFileName = ""; foreach ($ worksheet-> getDrawingCollection () as $ drawing) {$ xy = $ drawing-> getCoordinates (); $ path = $ basePath; // for xlsxif ($ drawing instanceof PHPExcel_Worksheet_Drawing) {$ filename = $ drawing-> getPath (); $ imageFileName = $ drawing-> getIndexedFilename (); $ path = $ path. $ drawing-> getIndexedFilename (); copy ($ filename, $ path); $ result [$ xy] = $ path; // for xls} else if ($ drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {$ image = $ drawing-> getImageResource (); $ renderingFunction = $ drawing-> getRenderingFunction (); switch ($ renderingFunction) {case PHPExcel_Worksheet_MemoryDrawing: RENDERING_JPEG: $ imageFileName = $ drawing-> getIndexedFilename (); $ path = $ path. $ drawing-> getIndexedFilename (); imagejpeg ($ image, $ path); break; case PHPExcel_Worksheet_MemoryDrawing: RENDERING_GIF: $ imageFileName = $ drawing-> getIndexedFilename (); $ path = $ path. $ drawing-> getIndexedFilename (); imagegif ($ image, $ path); break; case PHPExcel_Worksheet_MemoryDrawing: RENDERING_PNG: $ imageFileName = $ drawing-> getIndexedFilename (); $ path = $ path. $ drawing-> getIndexedFilename (); imagegif ($ image, $ path); break; case PHPExcel_Worksheet_MemoryDrawing: RENDERING_DEFAULT: $ imageFileName = $ drawing-> getIndexedFilename (); $ path = $ path. $ drawing-> getIndexedFilename (); imagegif ($ image, $ path); break;} $ result [$ xy] = $ imageFileName;} return $ result ;}

Original article address: Use PhpExcel to read files in Excel and thank the original author for sharing them.

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.