Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

PhpSpreadsheet run as a Procedure

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: PhpSpreadsheet run as a Procedure

Unread post by kev1n »

I didn't test it myself but normally you can include the Composer-generated autoload file by adjusting the path to point to the parent directory or a different one that is not within the nuBuilder directory structure.

E.g.:

Code: Select all

require_once __DIR__ . '/../vendor/autoload.php';
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: PhpSpreadsheet run as a Procedure

Unread post by treed »

Hi Kevin, I didn't do a good job asking my question. The require once works. Here's my code, it just writes a Hello World spread sheet as a test.

Code: Select all

echo "start";
require_once '/home/wcbbq-cloud/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$savePath='/home/wcbbq-cloud/var/www/html/db/temp/';
$spreadsheet = new Spreadsheet();
$activeWorksheet = $spreadsheet->getActiveSheet();
$activeWorksheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);
echo "Save";
$writer->save($savePath.'hello world.xlsx');

echo "success";
I'm getting to the save line and the the server log shows the following message.

Code: Select all

[Mon Apr 03 12:05:47.635903 2023] [proxy_fcgi:error] [pid 63086] [client 192.52.251.253:43396] AH01071: Got error 'PHP message: PHP Warning:  fopen(/home/wcbbq-cloud/var/www/html/db/temp/hello world.xlsx): Failed to open stream: No such file or directory in /home/wcbbq-cloud/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php on line 128', referer: https://dbs.winecountry-bbq.com/index.php
So it looks like it is unable to write the file. The $64 question is why doesn't it???
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: PhpSpreadsheet run as a Procedure

Unread post by kev1n »

Does it work if you leave out the path ? Is the path correct?

It appears that your question may not be directly related to nuBuilder. I would recommend asking your question on platforms like Stack Overflow or GitHub, where you can find a more relevant audience with expertise in the topic you are inquiring about. These platforms can provide better assistance and help you find the answer you need more effectively.

Good luck, and I hope you find the information you're looking for!
Post Reply