QiandaoExport.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Admin\Exports\Jobfair;
  3. use App\Admin\Exports\RowExport;
  4. use Illuminate\Support\Collection;
  5. class QiandaoExport extends RowExport
  6. {
  7. public $name = '';
  8. function __construct($name){
  9. $this->name = $name;
  10. }
  11. /**
  12. * 设置标题,返回标题数组
  13. * @return array
  14. */
  15. public function headings(): array
  16. {
  17. return [
  18. '参会企业',
  19. '预定展位',
  20. '签到时间'
  21. ];
  22. }
  23. /**
  24. * 处理行数据
  25. * @param Model $row
  26. * @return array
  27. */
  28. public function map($row): array
  29. {
  30. $result['companyname'] = $row['companyname'];
  31. $result['position_id'] = $row['position_id'];
  32. $result['signed_time'] = $row['signed_time'];
  33. return $result;
  34. }
  35. /**
  36. * 设置文件名
  37. * @return string
  38. */
  39. public function getFilename(): string
  40. {
  41. return $this->name.".xlsx";
  42. }
  43. /**
  44. * 格式化指定列.
  45. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  46. * @return array
  47. */
  48. public function columnFormats(): array
  49. {
  50. return [
  51. ];
  52. }
  53. }