Export MySQL Data to Excel using PHPSpreadsheet in CodeIngiter

Опубликовано: 22 Май 2021
на канале: Knowledge Thrusters
6,749
65

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 ,
firstly include vendor/autoload.php file
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);
$writer- save('hello world.xlsx');

For download of excel file, you have to add headers
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="hello_world.xlsx"');

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:
https://phpspreadsheet.readthedocs.io...

Starting hello world:
https://phpspreadsheet.readthedocs.io...

Code Link:
https://github.com/sushma-singh-yadav...

Playlist:
   • PHPSpreadsheet in CodeIgniter  
#codeigniter #knowledgethrusters


Смотрите видео Export MySQL Data to Excel using PHPSpreadsheet in CodeIngiter онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Knowledge Thrusters 22 Май 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,749 раз и оно понравилось 65 людям.