//composer require phpoffice/phpexcel
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
public function export()
{
ini_set("memory_limit","-1");
set_time_limit(0);
$spreadsheet = new Spreadsheet();
$lists = $this->model->select();
foreach ($lists as $k => $row) {
$select[$k][] = $row['id'];
$select[$k][] = $row['mobile'];
$select[$k][] = $row['online_status'] ==1 ? '在线' : '离线';
}
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1','ID');
$sheet->setCellValue('B1','手机号码');
$sheet->setCellValue('C1','在线状态');
$sheet->fromArray(
$select,
null,