【发布时间】:2022-01-26 23:37:30
【问题描述】:
我正在使用matwebsite包下载excel文件,它下载得很完美,但是某些列值以其他格式显示(1244+67866)(注意:-当时显示的字母更多),如何解决这个错误请帮我解决这个问题..
class BooksExport implements FromCollection, WithHeadings, WithEvents, ShouldAutoSize
{
protected $data = null;
public function __construct($data)
{
$this->data = $data;
}
public function collection()
{
return collect($this->data);
}
public function headings(): array
{
return [
'Object',
'Id',
'Return date',
'status',
'amount'
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// All headers - set font size to 14
$cellRange = 'A1:E1';
$event->sheet->getDelegate()->getStyle($cellRange)->getFont()->setSize(12);
// Apply array of styles to B2:G8 cell range
$styleArray = [
'borders' => [
'outline' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
'color' => ['argb' => 'FFFF0000'],
]
]
];
},
];
}
}
my downloaded excel
object id return-date status amount
Book1 345 24-01-2020 returned 98+99 // original is ==> 9898989
Book2 543 22-01-566 done 1425
【问题讨论】: