Showing posts with label How to Generate Excel Report in Codeigniter. Show all posts
Showing posts with label How to Generate Excel Report in Codeigniter. Show all posts

Friday, 20 February 2015

Generate Excel Report in Codeigniter

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