Home  >  Article  >  Backend Development  >  Using PHPexcel in Yii to obtain data in excel_PHP tutorial

Using PHPexcel in Yii to obtain data in excel_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:31:44982browse

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/761777.htmlTechArticle1. The code in view is as follows: form name="frmBatchSettle" id="" action="" method=" post" enctype="multipart/form-data" Please select the EXCEL file containing the batch IP name input type="file" name="bat...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn