1 pièce(s) jointe(s)
[PHPspreadsheet] Parse error: syntax error, unexpected '=' in Calculation.php line 2460
Bonjour,
J'essaie de réaliser l'export d'un fichier xlsx avec multiples worksheet en utilisant phpspreadsheet mais lorsque j'essaye d'instancier un 'new Spreadsheet()' j'obtient l'erreur suivante:
Pièce jointe 520414
Voici le code qui traite cette action:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<?php
namespace Sngm\ApiBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class DeclarationAccidentController extends Controller {
public function exportAction(Request $request) {
$em = $this->getDoctrine()->getManager();
$dateDebut = "2019/09/01"; $dateFin = "2019/11/01";
$spreadsheet = new Spreadsheet(); // Ligne 26
$declarationSheet = $spreadsheet->getActiveSheet();
$declarationSheet->setCellValue('A1', 'GeeksForGeeks!');
$writer = new Xlsx($spreadsheet);
$writer->save("declaration-accident-du-" . $dateDebut . "-au-" . $dateFin);
}
} |
J'utilise Symfony, donc je peux mettre la stacktrace:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Symfony\Component\Debug\Exception\FatalThrowableError:
Parse error: syntax error, unexpected '='
at vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php:2460
at Symfony\Component\Debug\DebugClassLoader->loadClass('PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation')
at spl_autoload_call('PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation')
(vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Spreadsheet.php:472)
at PhpOffice\PhpSpreadsheet\Spreadsheet->__construct()
(src\Sngm\ApiBundle\Controller\DeclarationAccidentController.php:26)
at Sngm\ApiBundle\Controller\DeclarationAccidentController->exportAction(object(Request))
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:151)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:68)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:202)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(web\app_dev.php:28) |
Je précise que j'utilise la version 7.1.26 de PHP, ce qui devrait suffire pour cette librairie qui requiert la version 7.1 minimum.
Merci d'avance.