2017-04-03 02:52:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
|
|
|
|
2017-12-17 07:34:40 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Csv;
|
2017-11-08 15:48:01 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2017-04-03 02:52:35 +00:00
|
|
|
|
2017-11-08 15:48:01 +00:00
|
|
|
class CsvTest extends TestCase
|
2017-04-03 02:52:35 +00:00
|
|
|
{
|
2017-04-17 16:51:53 +00:00
|
|
|
public function testDelimiterDetection()
|
|
|
|
{
|
2017-12-17 07:34:40 +00:00
|
|
|
$reader = new Csv();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertNull($reader->getDelimiter());
|
2017-04-17 16:51:53 +00:00
|
|
|
|
|
|
|
$filename = __DIR__ . '/../../data/Reader/CSV/semicolon_separated.csv';
|
|
|
|
$spreadsheet = $reader->load($filename);
|
|
|
|
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertSame(';', $reader->getDelimiter(), 'should be able to infer the delimiter');
|
2017-04-17 16:51:53 +00:00
|
|
|
|
|
|
|
$actual = $spreadsheet->getActiveSheet()->getCell('C2')->getValue();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertSame('25,5', $actual, 'should be able to retrieve values with commas');
|
2017-04-17 16:51:53 +00:00
|
|
|
}
|
2017-04-03 02:52:35 +00:00
|
|
|
}
|