Dear KoolReport team,
I am facing this issue from last 2 days. Already I posted yesterday in Forum No#1210. But I didn't get reply. I want to Download Excel file. It genrates the Table structure, But below of table structure it shows the following error
Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\CI3\application\libraries\koolreport\core\src\KoolReport.php:455)
and I want to make download the report in Excel,CSV or ODS.
How can I overcome this error. Please help me.
class Excel extends CI_Controller
{
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'] : 'XLSX';
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');
}
}
}
class ExcelReport_Ex extends \koolreport\KoolReport
{
use \koolreport\codeigniter\Friendship;
use \koolreport\excel\BigSpreadsheetExportable;
public function settings()
{
return array(
"dataSources"=>array(
"excel_export"=>array(
"connectionString"=>"sqlsrv:Server=SQLPC;Database=MainiDM",
"username"=>"sa",
"password"=>"sa1234",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('excel_export')
->query("SELECT * from EnquiryDataView")
->pipe($this->dataStore('excel_data'));
}
}
<form method="post">
<button type="submit" class="btn btn-primary" formaction="<?php echo site_url();?>\Excel?type=XLSX">Download XLSX</button>
<button type="submit" class="btn btn-primary" formaction="export.php?type=ODS">Download ODS</button>
<button type="submit" class="btn btn-primary" formaction="export.php?type=CSV">Download CSV</button>
</form>
</div>
<div class='box-container'>
<div>
<?php
Table::create(array(
"dataSource"=>$this->dataStore('excel_data'),
"paging"=>array(
"pageSize"=>5
)
));//Table create End
?>
</div>