Laravel Excel 3.1 怎么样导出图片的?
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithHeadings;
class CollectionsExport implements FromCollection, WithMapping, WithHeadings, ShouldAutoSize
{
use Exportable;
protected $collections;
public function __construct($collections)
{
$this->collections = $collections;
}
public function collection()
{
return $this->collections;
}
public function map($collection): array
{
return [
$collection->id,
$collection->name,
$collection->identity_card . ' ',
$collection->gender_name,
$collection->household_register,
$collection->residential_district,
$collection->unit_number,
$collection->corridor_number,
$collection->door_number,
$collection->identity_card_images[0] ?? null,
$collection->identity_card_images[1] ?? null,
$collection->personnel_images[0] ?? null,
$collection->personnel_images[1] ?? null,
$collection->personnel_images[2] ?? null,
$collection->created_at->toDateTimeString(),
$collection->status_name,
];
}
/**
* @return array
*/
public function columnFormats(): array
{
return [
'C' => NumberFormat::FORMAT_TEXT,
//'C' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,
];
}
public function headings(): array
{
return [
'ID',
'姓名',
'身份证号码',
'性别',
'户籍',
'现住小区',
'单元号',
'楼道号',
'门牌号',
'身份证相片正面',
'身份证相片反面',
'人员相片1',
'人员相片2',
'人员相片3',
'提交时间',
'审核状态',
];
}
}
我的照片是一个URL地址来的,怎么样可以导出相片呢?
怎么样把数据转为字符串?
'C' => NumberFormat::FORMAT_TEXT,
这样子好象没有效果,我现在做法是加了一个空格
推荐文章: