mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-19 23:30:43 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Worksheet\Table;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Table;
|
|
|
|
class Issue3659Test extends SetupTeardown
|
|
{
|
|
public function testTableOnOtherSheet(): void
|
|
{
|
|
$spreadsheet = $this->getSpreadsheet();
|
|
$sheet = $this->getSheet();
|
|
$sheet->setTitle('Feuil1');
|
|
$tableSheet = $spreadsheet->createSheet();
|
|
$tableSheet->setTitle('sheet_with_table');
|
|
$tableSheet->fromArray(
|
|
[
|
|
['MyCol', 'Colonne2', 'Colonne3'],
|
|
[10, 20],
|
|
[2],
|
|
[3],
|
|
[4],
|
|
],
|
|
null,
|
|
'B1',
|
|
true
|
|
);
|
|
$table = new Table('B1:D5', 'Tableau1');
|
|
$tableSheet->addTable($table);
|
|
$sheet->setSelectedCells('F7');
|
|
$tableSheet->setSelectedCells('F8');
|
|
self::assertSame($sheet, $spreadsheet->getActiveSheet());
|
|
$sheet->getCell('A1')->setValue('=SUM(Tableau1[MyCol])');
|
|
$sheet->getCell('A2')->setValue('=SUM(Tableau1[])');
|
|
$sheet->getCell('A3')->setValue('=SUM(Tableau1)');
|
|
$sheet->getCell('A4')->setValue('=CONCAT(Tableau1)');
|
|
self::assertSame(19, $sheet->getCell('A1')->getCalculatedValue());
|
|
self::assertSame(39, $sheet->getCell('A2')->getCalculatedValue());
|
|
self::assertSame(39, $sheet->getCell('A3')->getCalculatedValue());
|
|
self::assertSame('1020234', $sheet->getCell('A4')->getCalculatedValue(), 'Header row not included');
|
|
self::assertSame('F7', $sheet->getSelectedCells());
|
|
self::assertSame('F8', $tableSheet->getSelectedCells());
|
|
self::assertSame($sheet, $spreadsheet->getActiveSheet());
|
|
}
|
|
}
|