Generate Excel Report in Codeigniter
1.Controller file its just for examplle
$data['excel_data'] = $this->excel_model->view(); (this value with array and in model you should be create view function)
2. View file
These 3 line for generate excel report those line should be top on the view file
<?php
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="DonationList.xls"');
header('Cache-Control: max-age=0');
?>
<table width="100%" border="1">
<tr>
<th>Id</th>
<th>Donor Name</th>
</tr>
<?php foreach ($excel_data as $row): ?>
<tr>
<td><?php echo $row->id; ?></td>
<td><?php echo $row->name; ?></td>
</tr>
</table>
once you run this type file in Codeigniter you get downloadable excel sheet
Generate Excel Report in Codeigniter
nice it working
ReplyDeleteThank you jishan siddique
Deletewhat do you with :
ReplyDelete$data['excel_data'] = $this->excel_model->view(); (this value with array and in model you should be create view function) ??
Hi Mohanad
ReplyDeleteThat is model function to fetch the data $this->excel_model->view() and this is array data passing to view file $data['excel_data']
I hope understand the query
let me know if u have any query