当前位置: 首页>>代码示例>>PHP>>正文


PHP Excel::load方法代码示例

本文整理汇总了PHP中Maatwebsite\Excel\Facades\Excel::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Excel::load方法的具体用法?PHP Excel::load怎么用?PHP Excel::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Maatwebsite\Excel\Facades\Excel的用法示例。


在下文中一共展示了Excel::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: csvToRespondents

 static function csvToRespondents($file, $project_id)
 {
     $respondents = Excel::load($file, function ($reader) {
         $reader->toArray();
     });
     $respondents = $respondents->parsed;
     $count = null;
     foreach ($respondents as $respondent) {
         $count++;
         $new = Respondent::create(['first_name' => $respondent->first_name, 'last_name' => $respondent->last_name, 'gender' => $respondent->gender, 'dob' => $respondent->dob, 'project_id' => $project_id]);
         if (isset($respondent->email) && $respondent->email != null) {
             $email = RespondentEmail::firstOrCreate(['project_id' => $project_id, 'address' => $respondent->email]);
             $email->type = $respondent->type;
             $email->save();
             $new->emails()->save($email);
         }
         if (isset($respondent->phone) && $respondent->phone != null) {
             $ph_num = Uploader::cleanPhoneNumber($respondent->phone);
             $phone = RespondentPhone::firstOrCreate(['project_id' => $project_id, 'number' => $ph_num]);
             $phone->type = $respondent->phone_type;
             $phone->save();
             $new->phones()->save($phone);
         }
         if (isset($respondent->email) && $respondent->email != null) {
             $address = RespondentAddress::firstOrCreate(['project_id' => $project_id, 'street_number' => $respondent->street_number, 'street_name' => $respondent->street_name, 'apt' => $respondent->apt, 'city' => $respondent->city, 'state' => $respondent->state, 'zip' => $respondent->zip, 'type' => $respondent->address_type]);
             $new->addresses()->save($address);
         }
     }
     return $count;
 }
开发者ID:salaback,项目名称:nable,代码行数:30,代码来源:Uploader.php

示例2: insertArticles

 private function insertArticles($filename)
 {
     $i = 0;
     $filename = 'storage/app/' . $filename;
     Excel::load($filename, function ($reader) use($i) {
         $results = $reader->get();
         foreach ($results as $article) {
             $NoEstaEnLaBD = is_null(Article::where('product_code', $article['codigo'])->first());
             if ($NoEstaEnLaBD) {
                 // si el articulo _NO_ se encuentra en la base de datos
                 if (is_null($article['serializable'])) {
                     $serializable = 0;
                 } else {
                     $serializable = $article['serializable'];
                 }
                 $a = Article::create(['product_code' => $article['codigo'], 'unit' => $article['ub'], 'name' => $article['descripcion'], 'barcode' => $article['barcode'], 'fav' => $article['fav'], 'serializable' => $serializable, 'active' => $article['activo']]);
                 $i++;
             } else {
                 // si el codigo se encuentra en la base de datos
             }
         }
     });
     // Fin del Excel::load
     return $i;
 }
开发者ID:johanWP,项目名称:pandora,代码行数:25,代码来源:ImportController.php

示例3: postImportContacts

 /**
  * @param Request $request
  * @return View
  */
 public function postImportContacts(Request $request)
 {
     $start = microtime(true);
     $authenticated_user = $request->user();
     $creation_data = new CRUDResultData();
     $file = Input::file('imported_contacts');
     if (is_null($file)) {
         $extension = 'ERROR';
         $creation_data->extra_info .= 'No file uploaded. ';
     } else {
         $extension = $file->getClientOriginalExtension();
     }
     if ($extension == 'xls' or $extension == 'xlsx') {
         $php_excel = Excel::load($file->getPathname());
         $worksheet = $php_excel->setActiveSheetIndex(0)->toArray();
         $validation_data = $this->validateExcel($worksheet);
         if ($validation_data->success == false) {
             $creation_data = $validation_data;
         } else {
             $creation_data->success = true;
             $creation_data->extra_info = $validation_data->extra_info;
             $this->insertFromExcel($worksheet, $authenticated_user);
         }
     } elseif ($extension == 'csv' or $extension == 'tsv') {
     }
     $creation_data->extra_info .= 'Time to finish: ' . round((microtime(true) - $start) * 1000, 3) . ' ms. ';
     $creation_data->extra_info .= 'Uploaded by: ' . $authenticated_user->name . ' - ' . $authenticated_user->email . '. ';
     $this->logImportResult($creation_data, $authenticated_user);
     return View('contacts/import_contact')->with('creation_data', $creation_data);
 }
开发者ID:jsrc1115,项目名称:VOIQTest,代码行数:34,代码来源:ImportController.php

示例4: excel

 public function excel(Request $request)
 {
     try {
         Log::info(Input::file('input_excel'));
         Excel::load($request->file('input_excel'), function ($reader) {
             $array = $reader->toArray();
             Log::info($array);
             $banqueId = $this->gestSession->addBanqueByExcel($array[0]);
             Log::info("IdBanque1 " . $banqueId);
             $i = 1;
             while ($i < sizeof($array)) {
                 Log::info($array);
                 $titreIdGItem = $this->gestSession->addTitreGItemByExcel($array[$i]);
                 Log::info("IdTitreGItem " . $titreIdGItem);
                 $i++;
                 while ($i < sizeof($array) && $array[$i]["label_item"] != null) {
                     $this->gestSession->addItemByExcel($array[$i], $banqueId, $titreIdGItem);
                     $i++;
                 }
             }
         });
         return Redirect::back();
     } catch (\Exception $e) {
         echo "Format Incorrect";
     }
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:26,代码来源:BanqueController.php

示例5: importdata

 public function importdata(Request $request)
 {
     $results = null;
     $type = $request->input('type');
     $retdate = Excel::load($request->file('exelimport'), function ($reader) use($type) {
         $results = $reader->get();
         $ret = $results->toArray();
         //            var_dump($ret);
         foreach ($ret as $index => $value) {
             $EMP_ID = $value["emp_id"];
             $PLAN_ID = $value["plan_id"];
             $EQUITY_RATE = $value["equity_rate"];
             $DEBT_RATE = $value["debt_rate"];
             $MODIFY_DATE = $value["modify_date"];
             $EFFECTIVE_DATE = $value["effective_date"];
             $MODIFY_COUNT = $value["modify_count"];
             $MODIFY_COUNT_TIMESTAMP = $value["modify_count_timestamp"];
             $MODIFY_BY = $value["modify_by"];
             $insert = "INSERT INTO TBL_USER_FUND_CHOOSE (PLAN_ID,EMP_ID,EQUITY_RATE,DEBT_RATE,MODIFY_DATE,EFFECTIVE_DATE,MODIFY_COUNT,MODIFY_COUNT_TIMESTAMP,MODIFY_BY) VALUES(" . $PLAN_ID . ",'" . $EMP_ID . "'," . $EQUITY_RATE . "," . $DEBT_RATE . ",'" . $MODIFY_DATE . "','" . $EFFECTIVE_DATE . "'," . $MODIFY_COUNT . ",'" . $MODIFY_COUNT_TIMESTAMP . "','" . $MODIFY_BY . "')";
             DB::insert(DB::raw($insert));
         }
         $staturet = true;
         $data = "ok";
     });
     return response()->json(array('success' => true, 'html' => $retdate));
 }
开发者ID:FreelanceDArkman,项目名称:MEA,代码行数:26,代码来源:UserManagePlanController.php

示例6: _loadXls

 public static function _loadXls($url)
 {
     $data = Excel::load($url, function ($reader) {
         return $reader->all();
     });
     return $data;
 }
开发者ID:RMMusic,项目名称:CSE,代码行数:7,代码来源:Excel_.php

示例7: import

 public function import()
 {
     Excel::load('public/books.csv', function ($reader) {
         foreach ($reader->get() as $book) {
             Renglon::create(['descrip_renglon' => $book->id_tipo_, 'id_marca' => $book->unidad_medida, 'id_modelo' => $book->cantidad, 'unidad_medida' => $book->unidad_medida, 'cantidad' => $book->cantidad, 'existencia_minima' => $book->existencia_minima, 'foto_producto' => $book->foto_producto, 'cod_usua' => $book->cod_usua]);
         }
     });
     return Renglon::all();
 }
开发者ID:hramose,项目名称:Sistema-Control-de-Almacen,代码行数:9,代码来源:ExcelController.php

示例8: loadFragments

 protected function loadFragments(string $path) : Collection
 {
     return Excel::load($path)->all()->flatMap(function (RowCollection $sheet) {
         return $sheet->reject(function (CellCollection $row) {
             return empty(trim($row->group));
         })->map(function (CellCollection $row) use($sheet) {
             return $row->put('hidden', $sheet->getTitle() === 'hidden')->toArray();
         });
     });
 }
开发者ID:spatie-custom,项目名称:fragment-importer,代码行数:10,代码来源:Importer.php

示例9: postCargarUsuarios

 public function postCargarUsuarios(CargarUsuariosRequest $request)
 {
     $imagen = $request->file('imagen');
     $ruta = '/img/';
     $nombre = 'usuarios' . '.' . $imagen->guessExtension();
     $imagen->move(getcwd() . $ruta, $nombre);
     $result = Excel::load('public/img/usuarios.xlsx')->get();
     foreach ($result as $informe) {
         Usuario::create(['id' => $informe->id, 'nombre' => $informe->nombre, 'email' => $informe->email, 'password' => bcrypt($informe->password), 'tipo' => $informe->tipo]);
     }
     return redirect("/")->with('creada', 'Archivo subido');
 }
开发者ID:neyderangarita,项目名称:InformesEvaluarte,代码行数:12,代码来源:UsuarioController.php

示例10: importData

 public function importData(Request $request)
 {
     $file = $request->file('file');
     $name = time() . $file->getClientOriginalName();
     #$file->getClientOriginalName();
     $file->move('csv', $name);
     Excel::load('public/csv/' . $name, function ($reader) {
         $reader->each(function ($row) {
             Product::create($row->all());
         });
     });
     //message Done'
     #return redirect()->route('product.index');
 }
开发者ID:sharpscar,项目名称:becomeus,代码行数:14,代码来源:ProductController.php

示例11: importar

 public function importar()
 {
     Excel::load('Clientes.xlsx', function ($reader) {
         foreach ($reader->get() as $cliente) {
             \JLcourier\Entities\Cliente::create(['id' => $cliente->id, 'nombre' => $cliente->nombre, 'ruc' => $cliente->ruc, 'banco' => $cliente->banco]);
         }
     });
     Excel::load('Ordenes.xlsx', function ($reader) {
         foreach ($reader->get() as $orden) {
             \JLcourier\Entities\OrdenServicio::create(['id' => $orden->id, 'cliente_id' => $orden->cliente_id, 'fecha_inicio' => $orden->fecha_inicio, 'nro_orden' => $orden->nro_orden, 'tipo' => $orden->tipo, 'tiempo' => $orden->tiempo, 'estado' => $orden->estado]);
         }
     });
     return \JLcourier\Entities\Cliente::all();
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:14,代码来源:ClienteController.php

示例12: import

 public function import()
 {
     try {
         $file = Input::file('file');
         //$path = Input::file('pricelist')->getRealPath();
         $temp = null;
         Excel::load($file, function ($reader) use($temp) {
             //$reader->dump();
             // Loop through all rows
             $reader->each(function ($row) {
             });
         });
     } catch (Exception $e) {
         return 'Message: ' . $e->getMessage();
     }
     return redirect()->action('HomeController@index');
 }
开发者ID:x-Zyte,项目名称:nissanhippro,代码行数:17,代码来源:HomeController.php

示例13: Checkdate

 public function Checkdate(Request $request)
 {
     $results = null;
     $result = Excel::load($request->file('exelimport'))->get();
     $count = $result->count();
     //
     //      Excel::load($request->file('exelimport'), function ($reader) use($count) {
     //
     //            $results = $reader->get();
     //
     //            $ret = $results->toArray();
     //
     //
     //            $count = count($ret);
     //
     //
     //        });
     return response()->json(array('success' => true, 'html' => $count));
 }
开发者ID:FreelanceDArkman,项目名称:MEA,代码行数:19,代码来源:UserManageProfitController.php

示例14: parseFileImport

 public static function parseFileImport(\Illuminate\Http\Request $r)
 {
     $result = array('items' => '', 'file' => '');
     $config = \Config::get('user_import');
     $generateName = uniqid() . '.' . $r->file('file')->getClientOriginalExtension();
     $result['file'] = pathinfo($generateName)['basename'];
     $r->file('file')->move($config['path_price'], $result['file']);
     //$delimiter
     $excel = Excel::load($config['path_price'] . $result['file'], function ($reader) {
         $reader->noHeading();
     });
     if ($excel->getTotalRowsOfFile() > 10) {
         $excel = $excel->take(3)->get()->toArray();
     } else {
         $excel = $excel->get()->toArray();
     }
     $result['items'] = UserImport::formaterDataFile($excel, $generateName);
     return $result;
 }
开发者ID:filchakov,项目名称:angular_importer,代码行数:19,代码来源:UserImport.php

示例15: import

 public function import()
 {
     /************* Base ***********/
     Excel::load('data/base_stcs.csv', function ($reader) {
         foreach ($reader->get() as $employee) {
             Employee::create(["no_emp" => $employee->noemp, "first_name" => ucwords(mb_strtolower($employee->nombre, 'UTF-8')), "last_name" => '', "gender" => "f", "status" => 1, "payrollID" => 3, "syndicateID" => 1]);
         }
     });
     Excel::load('data/base_sthcs.csv', function ($reader) {
         foreach ($reader->get() as $employee) {
             Employee::create(["no_emp" => $employee->noemp, "first_name" => ucwords(mb_strtolower($employee->nombre, 'UTF-8')), "last_name" => '', "gender" => "f", "status" => 1, "payrollID" => 3, "syndicateID" => 2]);
         }
     });
     Excel::load('data/base_sitcs.csv', function ($reader) {
         foreach ($reader->get() as $employee) {
             Employee::create(["no_emp" => $employee->noemp, "first_name" => ucwords(mb_strtolower($employee->nombre, 'UTF-8')), "last_name" => '', "gender" => "f", "status" => 1, "payrollID" => 3, "syndicateID" => 3]);
         }
     });
     return Employee::all();
 }
开发者ID:Alexsflores,项目名称:rtcs,代码行数:20,代码来源:ImportCSVController.php


注:本文中的Maatwebsite\Excel\Facades\Excel::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。