无法导出为.xlsx格式

我试图将我的表格导出为.xlsx格式。 但是没有做到这一点。 到目前为止我做了这个:

header('Content-type: application/octet-stream'); header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); //should be a correct mimetype header('Content-Disposition:attachment; filename="contoh-1.xlsx"'); 

下面是错误: 在这里输入图像说明

这是我如何生成数据。 控制器:

 public function kategori_excel(){ $paramKategori = $this->input->get('CategoryCode'); $get_url_kategori = $this->ws_url->GetUrl('CategoryRetrieve?CategoryCode='.$paramKategori); $get_json_kategori = json_decode(file_get_contents($get_url_kategori), true); $data['itemKategoriToExcel'] = $get_json_kategori['Kategoris']; $this->load->view('kategori_excel', $data); } 

这里是观点:

 <table border='1' width="100%"> <tr> <th>Kode</th> <th>Nama</th> <th>Definisi</th> <th>Unsur Abstrak</th> <th>Alias</th> <th>Sumber Definisi</th> <th>Tanggal</th> <th>Tipe Tanggal</th> <th>Edisi</th> <th>Role</th> <th>Other Citation Detail</th> <th>Nama Katalog</th> <th>Nama Organisasi</th> </tr> <?php foreach($itemKategoriToExcel as $item): ?> <tr> <td><?php echo $item['KodeKategori'] ?></td> <td><?php echo $item['Nama'] ?></td> <td><?php echo $item['Definisi'] ?></td> <td><?php echo $item['UnsurAbstrak'] ?></td> <td><?php echo $item['Alias'] ?></td> <td><?php echo $item['SumberDefinisi'] ?></td> <td><?php echo $item['Tanggal'] ?></td> <td><?php echo $item['TipeTanggal'] ?></td> <td><?php echo $item['Edisi'] ?></td> <td><?php echo $item['Role'] ?></td> <td><?php echo $item['OtherCitationDetail'] ?></td> <td><?php echo $item['NamaKatalog'] ?></td> <td><?php echo $item['NamaOrganisasi'] ?></td> </tr> <?php endforeach; ?> </table> 

我该如何解决这个问题?