如何设置存储为文本的数字laravel excel?
这个实际数字如何设置存储为文本的数字laravel excel?,laravel,laravel-excel,Laravel,Laravel Excel,这个实际数字 6471050909740010 并在此处用excel替换结果 6.47105E+15 6471050909740000 这是我的密码 $collect = collect($model->toArray()); $excelData = Excel::create('Endorsement', function($excel) use ($collect) { $excel->sheet('Endorsement', functio
6471050909740010
并在此处用excel替换结果
6.47105E+15
6471050909740000
这是我的密码
$collect = collect($model->toArray());
$excelData = Excel::create('Endorsement', function($excel) use ($collect) {
$excel->sheet('Endorsement', function ($sheet) use ($collect) {
$this->template($sheet);
foreach ($collect as $key => $rest) {
$empid = strval($rest['empid']);
$i = $key+2;
$sheet->cell('A'.$i, $rest['ttype']);
$sheet->cell('H'.$i, $empid);
}
});
});
$collect
中的数据都是字符串事件,数字存储为字符串我认为您可以执行以下操作
$sheet->setCellValue('H'.$i, $empid);
而不是
$sheet->cell('H'.$i, $empid);
Larvel
maatwebsite/excel
Version2*
Excel::create('Endorsement', function ($excel) use ($collect) {
$excel->sheet('Endorsement', function ($sheet) use ($collect) {
$sheet->setColumnFormat(array(
'H' => \PHPExcel_Style_NumberFormat::FORMAT_TEXT,
'AS' => \PHPExcel_Style_NumberFormat::FORMAT_TEXT,
));
$this->template($sheet);
foreach ($collect as $key => $rest) {
$i = $key + 2;
$sheet->setCellValueExplicit('H' . $i, $rest['empid']);
$sheet->setCellValueExplicit('AS' . $i, $rest['account_no']);
}
});
});
也许你想看看