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


PHP Excel::create方法代码示例

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


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

示例1: exportOneSheet

 public function exportOneSheet($collection, array $columns, $title, $filename, $format = 'xls', $creator = '', $company = '')
 {
     $rows = [];
     $rows[] = array_values($columns);
     foreach ($collection as $item) {
         $row = [];
         foreach ($columns as $attribute => $title) {
             $pos = strpos($attribute, '.');
             if ($pos !== false) {
                 $right = $attribute;
                 while ($pos !== false) {
                     $left = substr($right, 0, $pos);
                     $right = substr($right, $pos + 1);
                     $pos = strpos($right, '.');
                     $relation = $item->{$left};
                 }
                 $row[] = $relation->{$right};
             } else {
                 $row[] = $item->{$attribute};
             }
         }
         $rows[] = $row;
     }
     return \Maatwebsite\Excel\Facades\Excel::create($filename, function ($excel) use($rows, $title, $creator, $company) {
         $excel->setTitle($title);
         $excel->setCreator($creator)->setCompany($company);
         $excel->sheet($title, function ($sheet) use($rows) {
             $sheet->fromArray($rows, null, 'A1', true, false);
         });
     })->download($format);
 }
开发者ID:am2studio,项目名称:laravel-exporter,代码行数:31,代码来源:Exporter.php

示例2: index

 /**
  * Create or update a note
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function index(Request $request)
 {
     $linehaul = $request->input('linehaul', null);
     $postalCode = $request->input('postalcode', null);
     $fresh = $request->input('fresh', false);
     $dummy = $request->input('dummy', false);
     //Damn strings
     if ($fresh == 'false') {
         $fresh = false;
     }
     if ($fresh) {
         $postalCodes = $this->getPostalCodes($linehaul, $postalCode);
     } else {
         $postalCodes = Cache::remember('postal_codes', 24 * 60, function () use($linehaul, $postalCode) {
             return $this->getPostalCodes($linehaul, $postalCode);
         });
     }
     if (!$dummy) {
         return Excel::create('PostalCodes' . Carbon::now()->toDateString(), function ($excel) use($postalCodes) {
             $excel->sheet('postalcodes', function ($sheet) use($postalCodes) {
                 $sheet->fromArray($postalCodes);
             });
         })->download('xls');
     }
     return 'DB UPDATED';
 }
开发者ID:dagmawiyehenew,项目名称:laravel-levapp,代码行数:32,代码来源:PostalCodeController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $requested = Input::get('request');
     $message = '';
     if ($requested == null || $requested == '' || $requested == 'showAll') {
         $users = $this->getActiveCompanyUsers(null);
         $keyword = '';
         if (count($users) == 25) {
             $message = "There are more users than are currently displayed. Please use the search filter.";
         }
         return view('goalSettings.list', compact('users', 'keyword', 'message'));
     } elseif ($requested == 'excel') {
         $keyword = Input::get('keyword');
         $users = $this->getActiveCompanyUsers($keyword);
         $data = array(array('Member Name', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'ANNUAL'));
         foreach ($users as $user) {
             array_push($data, array($user->first_name . ' ' . $user->last_name, $user->goalManagement->jan, $user->goalManagement->feb, $user->goalManagement->mar, $user->goalManagement->apr, $user->goalManagement->may, $user->goalManagement->jun, $user->goalManagement->jul, $user->goalManagement->aug, $user->goalManagement->sep, $user->goalManagement->oct, $user->goalManagement->nov, $user->goalManagement->dec, $user->goalManagement->annual));
         }
         Excel::create('revenueGoalSettings', function ($excel) use($data) {
             $excel->sheet('Revenue Goal Settings', function ($sheet) use($data) {
                 $sheet->fromArray($data);
             });
         })->export('xlsx');
     } else {
         $keyword = Input::get('keyword');
         $users = $this->getActiveCompanyUsers($keyword);
         if (count($users) == 25) {
             $message = "There are more users than are currently displayed. Please use the search filter.";
         }
         return view('goalSettings.list', compact('users', 'keyword', 'message'));
     }
 }
开发者ID:keiwerkgvr,项目名称:salesperformanceindicator,代码行数:37,代码来源:GoalSettingController.php

示例4: export

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function export($report)
 {
     $data = null;
     $title = null;
     if ($report == '1') {
         $data = session()->get('funciones');
         $title = 'Funciones';
     }
     if ($report == '2') {
         $data = session()->get('paises');
         $title = 'Paises';
     }
     if ($report == '3') {
         $data = session()->get('sedes');
         $title = 'Sedes';
     }
     if ($report == '4') {
         $data = session()->get('programas');
         $title = 'Programas';
     }
     if ($report == '5') {
         $data = session()->get('festivales');
         $title = 'Festivales';
     }
     $fechaIni = $data[0]['Fecha inicial'];
     $fechaFin = $data[0]['Fecha final'];
     Excel::create('Reporte DocumentaQro ' . $title . ' de ' . $fechaIni . ' hasta ' . $fechaFin, function ($excel) use($data) {
         $excel->sheet('Export', function ($sheet) use($data) {
             $sheet->fromArray($data);
         });
     })->export('xls');
 }
开发者ID:saulzini,项目名称:DocumentaQro,代码行数:37,代码来源:ExcelController.php

示例5: genCreditCardDealReport

 protected function genCreditCardDealReport($filename)
 {
     $self = $this;
     return Excel::create($filename, function ($excel) use($self) {
         $formatArr = ['J' => '@', 'K' => '@', 'L' => '@', 'M' => '@', 'N' => '@', 'O' => '@', 'P' => '@', 'Q' => '@', 'R' => '@', 'S' => '@', 'T' => '@', 'U' => '@', 'V' => '0', 'B' => '@', 'H' => '@', 'F' => '0', 'G' => '0'];
         ExcelHelper::genBasicSheet($excel, '表格', $formatArr, 'V', $self->getCreditCardDealQuery(), $self->genCreditCardDealHead());
     });
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:8,代码来源:CreditCardController.php

示例6: exportFileTest

 /**
  * Generates exported excel files
  *
  * @return excel file
  */
 public static function exportFileTest($reportArray = array(), $filename = 'Filenaname_here')
 {
     Excel::create($filename, function ($excel) use($reportArray) {
         $excel->sheet('Sheetname', function ($sheet) use($reportArray) {
             $sheet->fromArray($reportArray, null, 'A1', false, false);
         });
     })->export('xls');
 }
开发者ID:aXeLbEn12,项目名称:ReliefOps,代码行数:13,代码来源:ExcelExporter.php

示例7: exportToExcel

 /**
  * @param $date
  * @param $subscriptions
  * @return mixed
  */
 private function exportToExcel($date, $subscriptions)
 {
     return Excel::create('InscricoesParlamentoJuvenil-' . $date, function ($excel) use($subscriptions) {
         $excel->sheet('Inscricoes', function ($sheet) use($subscriptions) {
             $sheet->fromArray($subscriptions);
         });
     })->download('xls');
 }
开发者ID:alerj,项目名称:parlamentojuvenil,代码行数:13,代码来源:Subscriptions.php

示例8: export

 public function export()
 {
     Excel::create('Personal', function ($excel) {
         $excel->sheet('Sheetname', function ($sheet) {
             $sheet->fromArray($this->final);
         });
     })->export('xls');
 }
开发者ID:gerardo15,项目名称:Puzzle,代码行数:8,代码来源:AdminController.php

示例9: download

 public function download(Request $request)
 {
     $products = $this->productRepo->search($request)->get();
     Excel::create('Productos', function ($excel) use($products) {
         $excel->sheet('Listado', function ($sheet) use($products) {
             $sheet->loadView('products.partials.table', compact('products'));
         });
     })->export('xls');
 }
开发者ID:emejiasc85,项目名称:proyecto_seminario_privado,代码行数:9,代码来源:ProductsController.php

示例10: exportar

 public function exportar()
 {
     Excel::create('Ordenes', function ($excel) {
         $excel->sheet('Ordenes', function ($sheet) {
             $ordenes = \JLcourier\Entities\Cliente::join('orden_servicios', 'clientes.id', '=', 'orden_servicios.cliente_id')->select('orden_servicios.fecha_inicio', 'orden_servicios.nro_orden', 'nombre', 'orden_servicios.tipo', 'orden_servicios.tiempo', 'orden_servicios.estado')->get();
             $sheet->fromArray($ordenes);
         });
     })->export('xls');
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:9,代码来源:ItemController.php

示例11: exportar

 public function exportar()
 {
     Excel::create('Usuarios', function ($excel) {
         $excel->sheet('Usuarios', function ($sheet) {
             $usuarios = \JLcourier\Entities\User::all();
             $sheet->fromArray($usuarios);
         });
     })->export('xls');
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:9,代码来源:UserController.php

示例12: download

 public function download(Request $request)
 {
     $items = $this->inventoryRepo->search($request)->get();
     Excel::create('inventario', function ($excel) use($items) {
         $excel->sheet('Listado', function ($sheet) use($items) {
             $sheet->loadView('inventories.partials.table', compact('items'));
         });
     })->export('xls');
 }
开发者ID:emejiasc85,项目名称:proyecto_seminario_privado,代码行数:9,代码来源:InventoriesController.php

示例13: process

 public function process()
 {
     $self = $this;
     Excel::create($this->getFileName(), function ($excel) use($self) {
         ExcelHelper::genBasicSheet($excel, '銷貨', ['C' => '@', 'G' => '@', 'I' => '@'], 'K', $self->getSaleQuery(), $self->getExportHead()['sale']);
         ExcelHelper::genBasicSheet($excel, '退貨', ['C' => '@', 'G' => '@', 'I' => '@'], 'K', $self->getBackQuery(), $self->getExportHead()['back']);
     })->store('xls', storage_path('excel/exports'));
     return $msg = $this->send();
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:9,代码来源:ConceController.php

示例14: excel

 public function excel()
 {
     $qdn = Info::all();
     Excel::create('QDN', function ($excel) use($qdn) {
         $excel->sheet($this->yearNow(), function ($sheet) use($qdn) {
             $sheet->fromArray($qdn);
         });
     })->download('csv');
 }
开发者ID:rob1121,项目名称:qdn,代码行数:9,代码来源:ParetoController.php

示例15: datapeserta_excel

 public function datapeserta_excel()
 {
     $datapeserta = DataPeserta::all();
     Excel::create('datapeserta', function ($excel) use($datapeserta) {
         $excel->sheet('Sheet 1', function ($sheet) use($datapeserta) {
             $sheet->fromArray($datapeserta);
         });
     })->export('xls');
 }
开发者ID:indyka,项目名称:daftarulang,代码行数:9,代码来源:HomeController.php


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