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

I just include the function in controller
function dump(){
$this->db->select(‘user_name’, ‘first_name’);
// run joins, order by, where, or anything else here
$query = $this->db->get();

users is a table
user_name, first_name are fields


the result will be send into to_excel($query)

I given only original query .....

I found it easier to just use the stock dbutil method but specify tabs as delimiter.

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

you could try this site.

Microsoft XML Formats

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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