1.view中代碼如下:
2.controller中代碼如下:
if(isset($_FILES['batchFile']) && $_FILES['batchFile']['error']==0)
{
spl_autoload_unregister(array('YiiBase','autoload')); //登出YII的自動載入,採用手動匯入,PHPexcel有自己的載入功能
include_once(dirname(dirname(__FILE__)).'\extensions/PHPExcel.php'); //按照自己的路徑匯入類檔案
include_once(dirname(dirname(__FILE__)).'\extensions/PHPExcel/IOFactory.php');
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['batchFile']['tmp_name']); //匯入上傳的excel檔案的資料邏輯
$objWorksheet = $objPHPExcel->getActiveSheet(0); //擷取excel中sheet(0)的資料
spl_autoload_register(array('YiiBase','autoload')); //重新啟用YII的自動載入
$EXCEL_VALUE = array();
foreach ($objWorksheet->getRowIterator() as $row) //遍曆資料
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true);
foreach ($cellIterator as $cell)
{
$EXCEL_VALUE[] = $cell->getValue();
}
}
dump($EXCEL_VALUE);
這裡我只用到這些,其他的還不是很清楚,繼續研究。
參考:本人所用的PHPExcel版本為該地址資源:http://download.csdn.net/detail/btbdylq/3798155
http://www.bkjia.com/PHPjc/761777.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/761777.htmlTechArticle1.view中代碼如下: form name="frmBatchSettle" id="" action="" method="post" enctype="multipart/form-data" 請選擇包含批量IP稱的EXCEL檔案 input type="file" name="bat...