Dear Sir,
I implemented my code as following example "https://www.koolreport.com/examples/reports/excel/excel_template/"
I got the grid output. But the downloaded excel file shows corrupted data. Please provide me any solution. The Download Excel File is Very Very important feature in my project.
ExcelExport.php
class ExcelExport extends CI_Controller
{
public function index()
{
$this->load->helper('url');
$this->load->database('MainiDM');
include APPPATH."reports\ExcelExport_Ex.php";
$report = new ExcelExport_Ex;
$report->run()->render();
}
public function export()
{
$this->load->helper('url');
$this->load->database('MainiDM');
include APPPATH."reports\ExcelExport_Ex.php";
$report = new ExcelExport_Ex;
$report->run();
$report->exportToExcel('ExcelExport')->toBrowser("ExcelExport.xlsx");
}
ExcelExport_Ex.php
class ExcelExport_Ex extends \koolreport\KoolReport
{
use \koolreport\codeigniter\Friendship;
use \koolreport\amazing\Theme;
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
use \koolreport\export\Exportable;
use \koolreport\excel\ExcelExportable;
public function settings()
{
return array(
"dataSources"=>array(
"enquiry"=>array(
"connectionString"=>"......",
"username"=>"sa",
"password"=>"....",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('enquiry')
->query("SELECT * from EnquiryDataView")
->pipe($this->dataStore('exceldata'));
}
}
ExcelExport_Ex.view.php
<form>
<button type="submit" class="btn btn-primary" formaction="<?php echo site_url();?>/ExcelExport/export">Download Excel</button>
</form>
</div>
<div class='box-container'>
<div>
<?php
Table::create(array(
"dataSource"=>$this->dataStore('exceldata'),
"paging"=>array(
"pageSize"=>5
)
));
?>
</div>
</div>
ExcelExport.excel.php:
<?php
use \koolreport\excel\Table;
use \koolreport\excel\PivotTable;
use \koolreport\excel\BarChart;
use \koolreport\excel\LineChart;
$sheet1 = "Enquires";
?>
<meta>
and These are same as Example
<?php
$styleArray
?>
<div cell="A1" range="A1:N1" excelstyle='<?php echo json_encode($styleArray); ?>' >
Enquires
</div>
<div>Enquires</div>
<div>
<?php
Table::create(array(
"dataSource"=>$this->dataStore('exceldata'),
"headersExcelStyle" => [
'CustomerName' => [
'font' => [
'italic' => true,
'color' => [
'rgb' => '808080',
]
],
]
],
"columnsExcelStyle" => [
'CustomerName' => [
'font' => [
'italic' => true,
'color' => [
'rgb' => '808080',
]
],
]
],
));
?>