CodeIgniter Forums
Need to pass DB values to a Excel sheet - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Need to pass DB values to a Excel sheet (/showthread.php?tid=42047)



Need to pass DB values to a Excel sheet - El Forum - 05-24-2011

[eluser]cupidleomanoj[/eluser]
Hi to all,
I am using the latest version of CI, I need to pass the database vales to the excel sheet. Similar to an report generation using excel. can any one guide me please. Thanks in advance


Need to pass DB values to a Excel sheet - El Forum - 05-25-2011

[eluser]toopay[/eluser]
You may interesting to look at http://phpexcel.codeplex.com/


Need to pass DB values to a Excel sheet - El Forum - 05-25-2011

[eluser]cupidleomanoj[/eluser]
hi thanks for your reply, but am not clear with it, so can u please give me more examples please...


Need to pass DB values to a Excel sheet - El Forum - 05-26-2011

[eluser]iversonchen[/eluser]
yes, i am new here, may i know what is CI?


Need to pass DB values to a Excel sheet - El Forum - 05-27-2011

[eluser]gigas10[/eluser]
Controller
Code:
public function download() {
    $data['history'] = $this->History_model->get_all();
    $this->load->view('download', $data);
}
download.php
Code:
<?php
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=history_table.xls");
echo "ID\tComponent\tLine\tInspection Date\tInspection Value\tInspection Notes\tInspected by\n";
foreach($history AS $h) {
    echo $h->id. "\t" . $h->component . "\t" . $h->line . "\t" . $h->last_inspected . "\t" . $h->inspected_value . "\t" . $h->notes . "\t" . $h->inspected_by . "\n";
}

Change your columns as needed.