I Tried Many Thing To Implement PhpSpreadsheet in CakePHP 2.x , In CakePHP 4 It Worked For Me.
Finally I Tried things mentioned in given link blog
http://abakalidis.blogspot.com/2018/08/how-to-use-latest-phpofficespreadsheet.html
It solve all issue but it generating Xlsx file. For XLS it worked.
After putting PHPSpreadsheet SOrce TO Vender In App Folder.
I Use Following Code
<?php
use PhpOfficePhpSpreadsheetSpreadsheet;
use PhpOfficePhpSpreadsheetWriterXlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$spreadsheet->createSheet();
$writer->save('hello world.xlsx');
?>
For XLS I Replace 3 lines as below
<?php
use PhpOfficePhpSpreadsheetSpreadsheet;
use PhpOfficePhpSpreadsheetWriterXls;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xls($spreadsheet);
$spreadsheet->createSheet();
$writer->save('hello world.xls');
?>
This Code Worked , But For Xlsx It IS giving Error
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…