Last active
November 27, 2017 00:17
-
-
Save spacebit-official/dd35fdcc143039027bcc671627749856 to your computer and use it in GitHub Desktop.
PHPExcel_Excel_to_Db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function readExelFile($filepath){ | |
require_once __DIR__ . '/../classes/PHPExcel/PHPExcel.php'; //подключаем наш фреймворк | |
$ar=array(); // инициализируем массив | |
$inputFileType = PHPExcel_IOFactory::identify($filepath); // узнаем тип файла, excel может хранить файлы в разных форматах, xls, xlsx и другие | |
$objReader = PHPExcel_IOFactory::createReader($inputFileType); // создаем объект для чтения файла | |
$objPHPExcel = $objReader->load($filepath); // загружаем данные файла в объект | |
$ar = $objPHPExcel->getActiveSheet()->toArray(); // выгружаем данные из объекта в массив | |
return $ar; //возвращаем массив | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment