Created
February 5, 2015 16:54
-
-
Save petrozavodsky/2bf1c702252e63962ca4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
* Считывает данные из любого excel файла и созадет из них массив. | |
* $filename (строка) путь к файлу от корня сервера | |
*/ | |
function parse_excel_file( $filename ){ | |
// подключаем библиотеку | |
require_once dirname(__FILE__) . '/PHPExcel/Classes/PHPExcel.php'; | |
$result = array(); | |
// получаем тип файла (xls, xlsx), чтобы правильно его обработать | |
$file_type = PHPExcel_IOFactory::identify( $filename ); | |
// создаем объект для чтения | |
$objReader = PHPExcel_IOFactory::createReader( $file_type ); | |
$objPHPExcel = $objReader->load( $filename ); // загружаем данные файла в объект | |
$result = $objPHPExcel->getActiveSheet()->toArray(); // выгружаем данные из объекта в массив | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment