本文整理汇总了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);
}
示例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';
}
示例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'));
}
}
示例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');
}
示例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());
});
}
示例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');
}
示例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');
}
示例8: export
public function export()
{
Excel::create('Personal', function ($excel) {
$excel->sheet('Sheetname', function ($sheet) {
$sheet->fromArray($this->final);
});
})->export('xls');
}
示例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');
}
示例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');
}
示例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');
}
示例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');
}
示例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();
}
示例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');
}
示例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');
}