Files
oleibman 6083e393c1 Permit Read to Class Which Extends Spreadsheet
See discussion #4202. Users can extend Spreadsheet, but the readers cannot return the extended class. This is solved pretty easily by adding a protected method in BaseReader which returns a new Spreadsheet. Users can then extend the Reader which they want, overriding that method to return the extended class.
2025-03-13 12:01:33 -07:00

23 lines
466 B
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
class MySpreadsheet extends Spreadsheet
{
public function calcSquare(string $cellAddress): float|int|string
{
$value = $this->getActiveSheet()
->getCell($cellAddress)
->getValue();
if (is_numeric($value)) {
return $value * $value;
}
return '#VALUE!';
}
}