-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apache OpenOffice Creates Xls Using Wrong Case for Number Format Gene…
…ral (#2242) See issue #2239. Problem is dealt with at the source, by making sure that Reader Xls checks for use of 'GENERAL' rather than 'General'. There doesn't seem to be a reason to test in other places, or to test for other casing variants.
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/PhpSpreadsheetTests/Reader/Xls/NumberFormatGeneralTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xls; | ||
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; | ||
|
||
class NumberFormatGeneralTest extends AbstractFunctional | ||
{ | ||
public function testGeneral(): void | ||
{ | ||
$filename = 'tests/data/Reader/XLS/issue2239.xls'; | ||
$contents = file_get_contents($filename) ?: ''; | ||
self::assertStringContainsString('GENERAL', $contents); | ||
|
||
$reader = new Xls(); | ||
$spreadsheet = $reader->load($filename); | ||
$sheet = $spreadsheet->getSheetByName('Blad1'); | ||
if ($sheet === null) { | ||
self::fail('Expected to find sheet Blad1'); | ||
} else { | ||
$array = $sheet->toArray(); | ||
self::assertSame('€ 2.95', $array[1][3]); | ||
self::assertSame(2.95, $sheet->getCell('D2')->getValue()); | ||
self::assertSame(2.95, $sheet->getCell('D2')->getCalculatedValue()); | ||
self::assertSame('€ 2.95', $sheet->getCell('D2')->getFormattedValue()); | ||
self::assertSame(21, $array[1][4]); | ||
self::assertSame(21, $sheet->getCell('E2')->getValue()); | ||
self::assertSame(21, $sheet->getCell('E2')->getCalculatedValue()); | ||
self::assertSame('21', $sheet->getCell('E2')->getFormattedValue()); | ||
} | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
Binary file not shown.