composer下载
composer require phpoffice/phpspreadsheet
public function export()
{
$data = $this->model->field('type_name,image,statusswitch')->select();
//创建一个新的excel文档
$newExcel = new Spreadsheet();
//获取当前操作sheet的对象
$objSheet = $newExcel->getActiveSheet();
//设置当前sheet的标题
$objSheet->setTitle('课程分类');
//设置宽度为true,不然太窄了
$newExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
$newExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
$newExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
//设置第一栏的标题
$objSheet->setCellValue('A1', '分类名称')
->setCellValue('B1', '分类图片')
->setCellValue('C1&