What is the most simplist way to generate reports in Codeigniter framework? Is there any library available to do this task? Except charting what are the other resources to d
I used this for my .csv reports. it has the ability to change database fields name in csv file. here is the code.
public function export_csv() {
$file_name = 'File_name_'.date("Y-m-d h-i-s").'.csv';
$query = $this->db->query('SELECT
id as "Id", // id is table id and Id is the csv header field.
franchiseopt as "Nearest Location",
hear_about_us as "How did you hear about us?",
specify as "Specify",
email as "Email",
noguests as "Number of Guests",
eventdate as "Date of Event",
name as "Your Name",
phone as "Phone Number",
locationevent as "Location of Event",
message as "More Details"
FROM TABLE_NAME ORDER BY id DESC');
$this->load->dbutil();
$data = $this->dbutil->csv_from_result($query);
$this->load->helper('download');
force_download($file_name, $data);
exit();
}
Obviously You need to replace database table fields according to your table.