filmov
tv
Export MySQL Data to Excel using PHPSpreadsheet in CodeIngiter

Показать описание
In this video, you will be able to export mysql data to excel using phpspreadsheet.
Steps:
I have created one button with text download format, I will changing that to an anchor tag.
Pass the href of your controller function.
In controller ,
after that use
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
Spreadsheet - for creating a worksheet in excel
xlsx -for creating excel file
we will be passing worksheet (spreadsheet) to xlsx - this will create a excel file that contain a worksheet.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet-getActiveSheet();
$sheet- setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
For download of excel file, you have to add headers
save will save that in a particular folder
For download you need to pass php://output to download in excel
$writer- save("php://output");
Documentation:
Starting hello world:
Code Link:
Playlist:
#codeigniter #knowledgethrusters
Steps:
I have created one button with text download format, I will changing that to an anchor tag.
Pass the href of your controller function.
In controller ,
after that use
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
Spreadsheet - for creating a worksheet in excel
xlsx -for creating excel file
we will be passing worksheet (spreadsheet) to xlsx - this will create a excel file that contain a worksheet.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet-getActiveSheet();
$sheet- setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
For download of excel file, you have to add headers
save will save that in a particular folder
For download you need to pass php://output to download in excel
$writer- save("php://output");
Documentation:
Starting hello world:
Code Link:
Playlist:
#codeigniter #knowledgethrusters