EducationExport.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Admin\Exports\Caiqing;
  3. use App\Admin\Exports\RowExport;
  4. use Illuminate\Support\Collection;
  5. class EducationExport 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. }
  26. /**
  27. * 处理行数据
  28. * @param Model $row
  29. * @return array
  30. */
  31. public function map($row): array
  32. {
  33. $result = [];
  34. foreach ($row as $k => $v) {
  35. $result['name'] = $row['name'];
  36. $result['job_amount'] = $row['job_amount'].'';
  37. $result['job_rate'] = $row['job_rate'].'%';
  38. $result['resume_num'] = $row['resume_num'].'';
  39. $result['resume_rate'] = $row['resume_rate'].'%';
  40. $result['multiple'] = $row['multiple'].'';
  41. }
  42. return $result;
  43. }
  44. /**
  45. * 设置文件名
  46. * @return string
  47. */
  48. public function getFilename(): string
  49. {
  50. return $this->name.".xlsx";
  51. }
  52. /**
  53. * 格式化指定列.
  54. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  55. * @return array
  56. */
  57. public function columnFormats(): array
  58. {
  59. return [
  60. ];
  61. }
  62. }