KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Where should we save export.php file of Excel Export package in Codeigniter3 MVC architecture #1210

Open Sowmya opened this topic on on Dec 9, 2019 - 2 comments

Sowmya commented on Dec 9, 2019

I am using PHP Codeigniter3 MVC architecture. I am working on Export Excel package.... I followed same as your example.

I got Table data, but this data I want to be share to Excel File.

Where should I save the export.php file in Codeigniter3 MVC architecture. Either in Controllers or Reports folder.

Please give me the suggestion.

KoolReport commented on Dec 9, 2019

Instead of creating export.php, write your export code inside a controller's action.

Sowmya commented on Dec 10, 2019

Thanks for your reply. I wrote export.php code in controller, but it gives me error as follows

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\CI3\application\libraries\koolreport\core\src\KoolReport.php:455)

Filename: excel/FileHandler.php

My Controller is as follows:

public function index()
   {
   	$this->load->helper('url');
   	$this->load->database('MainiDM');
   		
   	   include APPPATH."reports\ExcelReport_Ex.php";
          $report = new ExcelReport_Ex;
          $report->run()->render();
         

         $type = isset($_GET['type'])? $_GET['type'] : 'CSV';

         if($type === 'XLSX')
         {
            $report->exportToXLSX('ExcelReportSpreadsheet')->toBrowser("ExcelReport.xlsx");
           }

         elseif($type === 'ODS')
         {
            $report->exportToODS('ExcelReportSpreadsheet')->toBrowser('ExcelReport.ods');
          }

         elseif($type === 'CSV')
         {
            $report->exportToCSV('ExcelReportSpreadsheet')->toBrowser('ExcelReport.csv');
          }

   	}

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Excel