安装依赖:composer require maatwebsite/excel

\Maatwebsite\Excel\Facades\Excel

new \App\Imports\ImportData()

\Maatwebsite\Excel\Facades\Excel::import(new \App\Imports\ImportData(), public_path(‘import_excel/filename.xls’));

laravel 5.5导入excel文件

在ImportData中处理excel的数据

小问题

  1. excel日期单元格格式并不一定是日期,有时读到的会是数字,需要处理:KaTeX parse error: Undefined control sequence: \PhpOffice at position 8: date = \̲P̲h̲p̲O̲f̲f̲i̲c̲e̲\PhpSpreadsheet…date)->format(‘Y-m-d’);
  2. 整个文件处理过程是个事务操作,过程中有异常就会整体回滚
  3. 未完,待续

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2021-06-09
  • 2021-11-19
  • 2021-06-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
相关资源
相似解决方案