Home >Backend Development >PHP Tutorial >Using PHPexcel in Yii to obtain data in excel_PHP tutorial
The code in 1.view is as follows:
Please select the EXCEL file containing the batch IP name value = ""
2. The code in the controller is as follows:
if(isset($_FILES['batchFile']) && $_FILES['batchFile']['error'] ==0)
{
spl_autoload_unregister(array('YiiBase','autoload')); // Unregister the automatic loading of YII and use manual import, PHPexcel Have your own loading function
Include_ONCE (DIRNAME (DIRNAME (__ FILE __)). > include_once(dirname(dirname(__FILE__)).'extensions/PHPExcel/IOFactory.php');
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['batchFile'][ 'tmp_name']); //Import the data logic of the uploaded excel file
$objWorksheet = $objPHPExcel->getActiveSheet(0); //Get the data of sheet(0) in excel
spl_autoload_register(array('YiiBase','autoload')); 🎜> EXCEL_VALUE = array();
foreach ($objWorksheet->getRowIterator() as $row) >
{
$cellIterator = $row->getCellIterator(); cellIterator->setIterateOnlyExistingCells(true);
foreach ($cellIterator as $cell)
>
}
dump($EXCEL_VALUE);
I only use these here, the others are not very clear yet, continue to study.
Reference: The PHPExcel version I am using is the address resource: http://download.csdn.net/detail/btbdylq/3798155