Welcome Guest, Not a member yet? Register   Sign In
Need to pass DB values to a Excel sheet
#1

[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
#2

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

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

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB