• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download in excel format

#11
[eluser]Tamilmani[/eluser]
I just include the function in controller
function dump(){
$this->load->plugin(‘to_excel’);
$this->db->use_table(‘users’);
$this->db->select(‘user_name’, ‘first_name’);
// run joins, order by, where, or anything else here
$query = $this->db->get();
to_excel($query);
}

users is a table
user_name, first_name are fields

thatsall

the result will be send into to_excel($query)


I given only original query .....

#12
[eluser]Natebot[/eluser]
I found it easier to just use the stock dbutil method but specify tabs as delimiter.

Code:
$data = $this->dbutil->csv_from_result($db_result , "\t" , "\r\n");

// we can set output headers with $this->output->set_headers() ...then we force the download.

force_download('file.xls' , $data);

In either case, it's not truely xls file but a tab delimited one and so some apps like Google Docs may choke on it, while others like Numbers will throw a warning on import. YMMV.

#13
[eluser]moodsey211[/eluser]
you could try this site.

Microsoft XML Formats


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.