How to create output in Excel format of Reports generated on screen

edited October 2014 in Modules
Hi,
I am able to get the data from database file displayed on to the screen. How to send this data to a output file in Microsoft Excel format. What function should i be using.

I am using the below give function in "projectwise_report_model"

function toolbar_list()
{

$query = $this->db->query("select pap_tblpayments.vPProjName as projectname, pap_tblprojectname.nProjCost as projectcost ,pap_tblprojectname.dProjStartdate as projstartdt, pap_tblprojectname.dProjEnddate as projenddate, pap_tblpayments.vPRate as labour350 From pap_tblprojectname LEFT JOIN pap_tblpayments ON pap_tblpayments.vPRate WHERE pap_tblpayments.vPRate='350' ");
$arr='';
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$arr[] =$row;
}
}
return $arr;
}
------
OUTPUT displayed on the screen

Projectwise Report
Project Name Project Cost Start date End date Labour @350/day
Daddy builders 25000 2013-11-05 2013-12-20 350
Daddy builders 50000 2014-01-01 2014-01-30 350
Daddy builders 30000 2014-02-11 0000-00-00 350
Daddy builders 25000 2013-11-05 2013-12-20 350
Daddy builders 50000 2014-01-01 2014-01-30 350
Daddy builders 30000 2014-02-11 0000-00-00 350
Fransua Mansion 25000 2013-11-05 2013-12-20 350
Fransua Mansion 50000 2014-01-01 2014-01-30 350
Fransua Mansion 30000 2014-02-11 0000-00-00 350

-----------
Need help to send the above data (report) to a output file in Excel format.

Thanks

Comments

  • edited 6:02AM
    The base_module_model has an export_data method you can use to get the data into a CSV format. This method is used if you set "exportable" in the MY_fuel_modules.php file for your particular projectwise module.

    If you are doing it outside of the module, CodeIgniter has a "force_download($filename, $data);" function you can use found in the download helper you can try using:
    https://ellislab.com/codeigniter/user-guide/helpers/download_helper.html
Sign In or Register to comment.