Tag: 拉拉维尔5.1

将数据导出到Laravel的Excel中

我想在我的项目中将导出数据转换为excel,但是在检查结果后,结果并不像我想要的那样。 在这里我想做一个结果是有一个标题表。 这个代码我的控制器: public function getExport(){ Excel::create('Export data', function($excel) { $excel->sheet('Sheet 1', function($sheet) { $products=DB::table('log_patrols') ->join("cms_companies","cms_companies.id","=","log_patrols.id_cms_companies") ->join("securities","securities.id","=","log_patrols.id_securities") ->select("log_patrols.*","cms_companies.name as nama_companies","securities.name as nama_security") ->get(); foreach($products as $product) { $data[] = array( $product->date_start, $product->date_end, $product->condition_status, $product->nama_security, $product->nama_companies, ); } $sheet->fromArray($data); }); })->export('xls'); } 这是我的问题结果: 它应该是: 我的问题是如何将数字更改为文本我想在表头中。 为了实现我的目标,我必须对代码做些什么改进? 注意 :我使用maatwebsite / excel

上传文件给出错误

我需要将.xlsxfile upload到数据库。 我有3列的db value,pin_num,password_num 。 我的代码是这样的 public function import(Request $request) { if($request->hasFile('file')) { $files = $request->file('file'); $file = fopen($files, "r"); while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { $excel = new Excel; $excel->value = $emapData[0]; $excel->pin_num = $emapData[1]; $excel->password_num = $emapData[2]; $excel->save(); } } return Redirect::to('dashboard/file/view'); 这个上传.csv文件成功,但它给uploading.xlsx文件错误错误是这样的 Undefined offset: 1 in AdminController.php line 36 […]

使用maatweb导入Excel表格到Laravel 5.1

我正试图学习如何将一个基本的excel表导入laravel 5.1 vname Vservice vphone vmobile test name test service test number 123232 test mobile 12344 我做了以下function public function ImportVlist() { Excel::load('/import.xlsx', function($reader) { $results = $reader->get(); foreach ($results as $key => $value) { foreach ($value as $key => $value1) { Vlist::create([ 'vname'=>$value1->vname, 'vservice' => $value1->vservice, 'vphone' => $value1->vphone, 'vmobile' => $value1->vmobile ]); } } […]

导出为ex​​cel文件一个特定的行logging

在laravel 5.1使用maatweb / Excel包我需要导出特定的行logging到当前页面id正在查看的excel文件 在我的VlistController public function export() { Excel::create('Company List', function($excel) { $excel->sheet('companies', function($sheet) { $data = Vlist::all(); $data = json_decode(json_encode($data),true); $companies = []; foreach ($data as $key => $value) { $company['vname']= $value['vname']; $company['vaddress']= $value['vaddress']; $companies[] = $company; } $sheet->fromArray($companies); }); })->download('xlsx'); } 在我的路线文件 Route::get('/vlist/{vlist}/export' , 'VlistController@export'); 在我的秀场看来 <li><a href="{{ action('VlistController@export', [$vlist->id]) }}"><i class='fa […]