I have been trying to use the PHPSpreadSheet library in Scriptcase. I go the library to work (limited only as not completely tested)
My development PC : Windows 11 Core i5 laptop
Scriptcase : Version 9.9 PHP Version 8.1.6
STEP 1: INSTALL COMPOSER (Needs PHP) on the DEVELOPMENT PC
a) I installed Composer and used the instructions of PHPSPreadsheet to install the PHPSpreadsheet
b) I used an exclusive folder called phpspread. I used command prompt, moved into the phpspread folder and ran the composer command
composer require phpoffice/phpspreadsheet
Note at this point the PHP should be working without errors or composer might throw errors. In my case, I had some issues with extension modules loading
c) I zipped up the phpspread folder
STEP 2: Create an Library in EXTERNAL LIBRARIES
a) I created a Library called PHPSSheet
b) I uploaded the filed zipped in – 1 © above
c) Use Library and save project libraries
STEP 3: Example Code in Blank application as follows
NOTE THIS CODE IS FROM THIS LINK OF SCRIPTCASE : PHPSpreadSheet library with Scriptcase
The following code is WIORKING & SAVE THE EXCEL FILE in the app Directory" .
Please note paths used in the include and code statements. Also if you refer to the example link USE statements are present but they somehow dont work. So each class reference reference requires the complete path as in - ‘new PhpOffice\PhpSpreadsheet\Spreadsheet()’;
sc_include_library(“prj”,“PHPSSheet”,“phpspread/vendor/autoload.php”);
// following example from https://code-boxx.com/create-excel-spreadsheet-php/
// Make a new spreadsheet
$spreadsheet = new PhpOffice\PhpSpreadsheet\Spreadsheet();
// get current actvie sheet (first sheet)
$sheet = $spreadsheet->getActiveSheet();
// set the value of cell A1 to hello world
$sheet->setCellValue(“A1”, “Hello World!”);
// make an xlsx writer object using the above spreadsheet
$writer = new PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
// write the file in current directory
$writer->save(“demo.xlsx”);
**There might be one major drawback in this approach. Any update to the PHPSpreadsheet library might have to go through the steps 1 & 2 and might break the Code. ** . It will be greatly appreciated if veteran users contribute their valuable inputs here for the benefit of other small developers like me. Forgive me if any errors
Suresh