Tag: 拉拉维尔

获取Laravel的总数

我正在尝试获取Laravel中上载的Excel文件中存在的总页数。 我正在上传的文件有3张。 所以我期待得到$counter = 3的输出。 码: $counter=0; Excel::load($fileDetails['file_path'], function($sheet) use($counter) { $sheet->each(function($sheet) use($counter) { echo "It works</br>"; $counter++; }); }); echo $counter; exit; 输出: It works It works It works 0 //– This is $counter, which is not get incremented. It has to be 3.

完成之后继续阅读Maatwebsite Excel软件包中的所有行以查找laravel

我正在使用Laravel 5和Maatwebsite Excel软件包来读取和写入Excel文件,但是我不确切地知道如何pipe理下一个情况 public function readExcel(Request $request){ $content = []; Excel::load('file.xls', function($reader){ $content = $reader->get(); }); // do more somethings and return return $content; } 事情是,当我返回$内容,没有什么variables,我有一个想法,$内容有初始值和Excel ::加载仍然没有完成和新的价值的内容没有设置。 谢谢。

如何从Laravel的当前search中导出数据到excel?

我的项目有问题,我需要从Laravel的search数据中导出我的表,我怎么能做到这一点先生? 有我的控制器和index.blade.php Controller.php这样 public function downloadExcel(Request $request, $type) { $data = TABLENAME::get()->toArray(); return Excel::create('FILENAME', function($excel) use ($data) { $excel->sheet('mySheet', function($sheet) use ($data) { $sheet->fromArray($data); }); })->download($type); } public function search(Request $request) { $query = Model_items::query(); if(Input::has('name')) { $query->where('name', $getName); } if(Input::has('phone')) { $query->where('phone', $getPhone); } $dataList = $query->paginate(10); return view('index', compact('dataList')); } Index.blade.php <div class="col-md-4"> […]

laravel excel只获取当前数据

我刚开始使用这个excel pakage maatwebsite / excel,我设法下载了excel。 但是,在创buildexcel时遇到一些困难 如何更改Excel中打印的date格式? 我看到有人用这样的东西,但为什么不能开展工作? $ sheet-> setColumnFormat(array('E'=>'d / m / y')); 如何从今天获取数据? 例如,我input了一些数据并保存到数据库中,当我下载excel时,它只显示数据而不显示过去的数据。 我怎么做? 有没有可能改变Excel的标题? 例如created_at更改为date 目前这里是我的代码: public function downloadExcel($type) { $data = personal_info::join('qualifications', 'qualifications.user_id', '=', 'personal_infos.id') ->select( 'personal_infos.id', 'personal_infos.name', 'personal_infos.email', 'qualifications.qualification', 'personal_infos.created_at') ->get() ->sortByDesc('created_at'); return Excel::create('test', function($excel) use ($data) { $excel->sheet('mySheet', function($sheet) use ($data) { $sheet->fromArray($data); $sheet->setColumnFormat(array('E' => 'd/m/y')); }); […]

Laravel:如何导入Excel文件到数据库

我想通过Excel文件导入一些数据到数据库。 但是,当上传注意到上传到数据库。 我不确定这里有什么问题,如果有人发现,希望能帮我find答案。 这是我的控制器: public function importExcel() { if(Input::hasFile('import_file')){ $path = Input::file('import_file')->getRealPath(); $data = Excel::load($path, function($reader){})->get()->toArray(); if(!empty($data) && $data->count()){ foreach ($data as $key => $value) { $insert[] = ['title' => $value->title, 'description' => $value->description]; } if(!empty($insert)){ DB::table('items')->insert($insert); // dd('Insert Record successfully.'); } } } return back(); } 这里是刀片视图: <html lang="en"> <head> <title>Import – Export Laravel […]

尝试在路由函数laravel中使用和ID

嗨,我试图使用路线的ID来创build该比赛的球员列表。 但是,我似乎无法得到我的Excel的创造者内的ID是可用的。 Route::get('toernooien/{id}/spelers/excelexport', function($id){ Excel::create('Export spelers toernooi '. $id, function($excel) { $excel->sheet('Sheetname', function($sheet) { $ingeschrevenspelers = \App\UserToernooi::with('users')->where('toernooiid', '=', $id)->get()->all(); foreach($ingeschrevenspelers as $ingeschrevenspeler){ $sheet->row($ingeschrevenspeler->users->id, array( 'Voornaam:' . $ingeschrevenspeler->users->voornaam, 'Tussenvoegsel:' . $ingeschrevenspeler->users->tussenvoegsel, 'Achternaam:' . $ingeschrevenspeler->users->achternaam, 'Woonplaats:' . $ingeschrevenspeler->users->woonplaats, 'Telefoonnummer:' . $ingeschrevenspeler->users->telefoonnummer, 'e-mail:' . $ingeschrevenspeler->users->email, )); } }); })->download('xls'); }); 我想在我的$ ingeschrevenspelers var里的get route函数中使用突出显示的ID来获取订阅该比赛的用户列表。 我试图在$ excel和$ sheet旁添加$ id […]

如何使用Laravel Excel在 – > download()之后redirect

无法在Laravel Excel的文档中find如何在download()之后redirect()。 我试过这样做 Excel::load('/bills/bill.template.xlsx', function($doc) { $sheet = $doc->setActiveSheetIndex(0); $sheet->setCellValue('G21', '{buyer}'); })->download('xlsx'); return redirect('/')->with('notification','custom msg'); 但它不起作用。

加载与Maatwebsite Laravel-Excel的超链接

我使用Maatwebsite Laravel-Excel将大型xlsx文件导入到我的数据库中。 它工作得很好,但我找不到方法来导入链接到文档中的某个单元格的超链接。 这些链接总是作为简单的文本处理,没有附加链接。 有没有办法接收不仅文本,而且还有链接或链接地址?

在Laravel 4.2中强制下载.xls文件

我有以下路线: Route::get('/download/{id}/{filename}', function($id, $filename) { // Check if file exists in app/storage/file folder $file_path = storage_path() .'/orders/'.'/'.$id.'/'. $filename; if (file_exists($file_path)) { // Send Download return Response::download($file_path, $filename, [ 'Content-Type: application/vnd.ms-excel; charset=utf-8' ]); } else { // Error exit('Requested file does not exist on our server!'); } })->where('filename', '[A-Za-z0-9\-\_\.]+'); 在Laravel下载一个excel文件格式/应用程序/存储(以前上传)。 我面临的问题是,下载的Excel文件是由Excel无法读取的。 如果我从FTP下载上传的文件没关系。 我尝试了Content-Type的所有types的头文件,但似乎没有任何工作。 是否有一个特殊的Excel文件头? 非常感谢。

更改标题excel导出php laravel

View post on imgur.com 这是我试图导出它时所具有的。 它默认使用属性键。 我想把它改成我自己的标题。 例如payStatus来付款。 这是我的代码: public function exportReferral($sourceRef){ ob_end_clean(); ob_start(); //At the very top of your program (first line) \Excel::create('ViecBonus ' . 'referal report', function($excel) use ($sourceRef) { $excel->sheet('ViecBonus Data', function($sheet) use ($sourceRef) { $sheet->fromModel($sourceRef); }); })->export('xlsx'); }