Hello friends, I am writing this blog which will help you to export data to excel sheet or you can say that it will write data into excel sheet with the help of 'php-export-data-class' library.
Lets start by creating function name called export(). I am having sample example of Students here. You can create your own code. You need to download php-export-data-class and place it in the component or inside the webroot folder.
For now I have already placed this file inside the webroot folder. After this file 'php-export-data.class.php' has been uploaded to webroot folder, now you need to include this file using require_once in export() function. Now define $exporter by typing the below code:
$exporter = new ExportDataExcel('browser', 'students.xls');
Here in above code we are writing 'browser' so that on load of the browser, export will begin as shown below:
Now in order to start streaming data to web browser write the below code:
Now finally we need to add heading row to the excel file, you can do this by typing the code: