mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-11 18:46:49 +00:00
30384ac043
This supersedes PR #607 by @christian-forgacs, who deserves all the credit for reporting the problem and devising the solution. The PR went stale in 2018, and it is just easier to resubmit a clean version rather than clean up the old one. Among the suggestions in the PR was that you should try to create a spreadsheet from scratch to demonstrate the problem rather than supply one. However, my attempts to match the failing spreadsheet do not have a problem when they are read. So, a supplied spreadsheet it is. Fix #1570. No sample spreadsheet was supplied with that issue, but I am almost certain that this is another example of the same problem. I am removing the stale label from that issue; it will be closed properly when this PR is merged.
71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xls as XlsReader;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Pr607Test extends TestCase
|
|
{
|
|
/**
|
|
* Test file with cell range expressed in unexpected manner.
|
|
*/
|
|
public static function testSumData(): void
|
|
{
|
|
$filename = 'tests/data/Reader/XLS/pr607.sum_data.xls';
|
|
$reader = new XlsReader();
|
|
$spreadsheet = $reader->load($filename);
|
|
|
|
$tests = [
|
|
'Test' => [
|
|
'A1' => 1,
|
|
'A2' => 2,
|
|
'A3' => 3,
|
|
'A4' => 4,
|
|
'A5' => 5,
|
|
'A6' => 6,
|
|
'A7' => 7,
|
|
'A8' => 8,
|
|
'A9' => 9,
|
|
'A10' => 10,
|
|
|
|
'B1' => 3,
|
|
'B2' => 4,
|
|
'B3' => 5,
|
|
'B4' => 6,
|
|
'B5' => 7,
|
|
'B6' => 8,
|
|
'B7' => 9,
|
|
'B8' => 10,
|
|
'B9' => 11,
|
|
'B10' => 12,
|
|
|
|
'C1' => 4,
|
|
'C2' => 6,
|
|
'C3' => 8,
|
|
'C4' => 10,
|
|
'C5' => 12,
|
|
'C6' => 14,
|
|
'C7' => 16,
|
|
'C8' => 18,
|
|
'C9' => 20,
|
|
'C10' => 22,
|
|
],
|
|
];
|
|
|
|
foreach ($tests as $sheetName => $testsForSheet) {
|
|
$sheet = $spreadsheet->getSheetByName($sheetName);
|
|
self::assertNotNull($sheet);
|
|
|
|
foreach ($testsForSheet as $cellCoordinate => $result) {
|
|
$calculatedValue = $sheet->getCell($cellCoordinate)->getCalculatedValue();
|
|
self::assertSame($result, $calculatedValue, "cell $cellCoordinate");
|
|
}
|
|
}
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|