當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Excel::setDelimiter方法代碼示例

本文整理匯總了PHP中Maatwebsite\Excel\Facades\Excel::setDelimiter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Excel::setDelimiter方法的具體用法?PHP Excel::setDelimiter怎麽用?PHP Excel::setDelimiter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Maatwebsite\Excel\Facades\Excel的用法示例。


在下文中一共展示了Excel::setDelimiter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 /**
  *	Test import.
  *
  *	@return boolean
  */
 public function import($fileWithPath, $delimiter = ',', $save = true)
 {
     $rows = Excel::setDelimiter($delimiter)->load($fileWithPath)->get();
     $pagePos = -99;
     $pageCounter = 1;
     foreach ($rows as $row) {
         // create a new step
         if ($pagePos != $row->page) {
             if ($pagePos >= 1) {
                 $page->items()->saveMany($items);
             }
             $page = new Page();
             if (trim($row->model) == 'Comproso\\Framework\\Models\\Page') {
                 $params = [];
                 // input validation
                 /*$validator = Validator::make($row->toArray(), [
                 						'recallable' => 'boolean',
                 						'returnable' => 'boolean',
                 						'template' => 'string',
                 						'operations_template' => 'string',
                 						'page_assets'	=> 'json'
                 					]);
                 
                 					// validation fail
                 					if($validator->fails())
                 					{
                 						\Log::error($validator->errors());
                 						return false;
                 					}*/
                 // set page call settings
                 $page->recallable = boolval($row->recallable);
                 $page->returnable = boolval($row->returnable);
                 if (!empty(trim($row->template))) {
                     $page->template = trim($row->template);
                 }
             } elseif (!empty(trim($row->page_template))) {
                 $page->template = trim($row->page_template);
             }
             // set page assets
             if (!empty(trim($row->page_assets))) {
                 $page->assets = json_encode(json_decode(trim($row->page_assets)));
             }
             // set operations template
             if (!empty(trim($row->operations_template))) {
                 $page->operations_template = $row->operations_template == "null" ? null : trim($row->operations_template);
             }
             $page->repetitions = is_null($row->repetitions) ? 0 : $row->repetitions;
             $page->repetition_interval = is_null($row->interval) ? null : $row->interval;
             $page->time_limit = is_null($row->time_limit) ? null : $row->time_limit;
             $page->position = $pageCounter;
             $this->pages()->save($page);
             $items = [];
             $pagePos = $row->page;
             $pageCounter++;
             $itemCounter = 1;
             if (trim($row->model) == 'Comproso\\Framework\\Models\\Page') {
                 continue;
             }
         }
         // create Item
         $item = new Item();
         $item->position = $itemCounter;
         $item->element_type = trim($row->model);
         // create Element
         $row->model = trim($row->model);
         $element = new $row->model();
         $element->implement($row);
         $element->save();
         $item->element_id = $element->id;
         $item->template = empty(trim($row->template)) ? $element->template() : trim($row->template);
         $item->name = empty(trim($row->name)) ? null : trim($row->name);
         $item->proceed = !isset($row->proceed) ? false : boolval($row->proceed);
         $item->cssId = empty(trim($row->cssid)) ? null : trim($row->cssid);
         $item->cssClass = empty($row->cssclass) ? null : trim($row->cssclass);
         $item->validation = empty(trim($row->validation)) ? 'string' : trim($row->validation);
         $items[] = $item;
         $itemCounter++;
     }
     // save last page
     $page->items()->saveMany($items);
     // set test assets
     //$this->assets = (isset($testAssets)) ? json_encode($testAssets) : null;
     // save if allowed
     if ($save) {
         $this->save();
     }
     return true;
 }
開發者ID:comproso,項目名稱:framework,代碼行數:93,代碼來源:Test.php


注:本文中的Maatwebsite\Excel\Facades\Excel::setDelimiter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。