PhpSpreadsheet
PhpSpreadsheet copied to clipboard
CacheInterface not working correctly
This is:
- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
That it lets me create a PHPSpreadSheet Object
What is the current behavior?
Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /data/web/e107911/html/Mur/api/vendor/psr/simple-cache/src/CacheInterface.php on line 34
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php
require 'vendor/autoload.php';
$fileName = 'Teilnehmerliste.xlsx';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet->setCellValue('A1', 'Ranking');
$sheet->setCellValue('B1', 'Startgruppe');
$sheet->setCellValue('C1', 'Start Nr.');
$sheet->setCellValue('D1', 'Vorname');
$sheet->setCellValue('E1', 'Nachname');
$sheet->setCellValue('F1', 'Mitglieder');
$sheet->setCellValue('G1', 'Kategorie');
$sheet->setCellValue('H1', 'Verein');
$sheet->setCellValue('I1', 'NAT');
$sheet->setCellValue('J1', 'Bund.');
$sheet->setCellValue('K1', 'Jahrgang');
$sheet->setCellValue('L1', 'Startzeit');
$sheet->setCellValue('M1', 'Zielzeit');
$sheet->setCellValue('N1', 'Zeit');
$sheet->setCellValue('O1', 'Penalty');
$sheet->setCellValue('P1', 'Laufzeit');
$sheet->setCellValue('Q1', 'Gap');
//Rest of filling...
$spreadsheet->getActiveSheet()->getStyle('A1:Q1')->getFont()->setBold(true);
foreach (range('D','K') as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
$spreadsheet->getActiveSheet()->setAutoFilter($spreadsheet->getActiveSheet()->calculateWorksheetDimension());
$spreadsheet->getActiveSheet()->getStyle("A1:Q$row")->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
$writer = new Xlsx($spreadsheet);
try {
$writer->save($fileName);
} catch (\PhpOffice\PhpSpreadsheet\Writer\Exception $e) {
echo "An PhpOffice error occured: {$e->getMessage()}<br>";
}
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
- [ ] Reader
- [ ] Writer
- [ ] Styles
- [ ] Data Validations
- [ ] Formula Calculations
- [ ] Charts
- [ ] AutoFilter
- [ ] Form Elements
- [x] simple-cache package
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
I only tested xlsx
Which versions of PhpSpreadsheet and PHP are affected?
Unlike #3689 I actually use PHP 8.2 and the newest version of PhpSpreadsheet
PHPInfo:
Are you running PhpSpreadsheet from the command line, or through the web. If through the CLI, then what CLI version of PHP are you running?
I am running it through the Web on a apache web server
Despite your Phpinfo screenshot, I don't see how the error message you're seeing could be caused by anything other than running the code using Php7.4 (or lower). Perhaps you can try a small experiment. In your vendor directory (which should hold your phpoffice/phpspreadsheet directory), there should be a composer directory which holds a file called platform_check.php. Near the start of that file, there should be the following lines:
if (!(PHP_VERSION_ID >= 70400)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
}
If 70400 (or lower) is not in that first line, I don't know how to proceed. However, if it is, can you change that line to:
if (!(PHP_VERSION_ID >= 80000)) {
Then run your script again, and see if the error message is the same. If it is, try 80400 and see if anything changes. Then change it back to the original. Perhaps the result of this test will allow us to understand the problem better.
No update in a year, closing.