OverallExport.php 1.3 KB

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