2017-12-17 07:34:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
|
|
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
|
2018-01-01 15:53:28 +00:00
|
|
|
class MergedCellsTest extends AbstractFunctional
|
2017-12-17 07:34:40 +00:00
|
|
|
{
|
|
|
|
public function providerFormats()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['Html'],
|
|
|
|
['Xls'],
|
|
|
|
['Xlsx'],
|
|
|
|
['Ods'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerFormats
|
|
|
|
*
|
|
|
|
* @param string $format
|
|
|
|
*/
|
2020-05-18 04:49:57 +00:00
|
|
|
public function testMergedCells($format): void
|
2017-12-17 07:34:40 +00:00
|
|
|
{
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
$spreadsheet->setActiveSheetIndex(0);
|
|
|
|
$spreadsheet->getActiveSheet()->setCellValue('A1', '1');
|
|
|
|
$spreadsheet->getActiveSheet()->setCellValue('B1', '2');
|
|
|
|
$spreadsheet->getActiveSheet()->setCellValue('A2', '33');
|
|
|
|
$spreadsheet->getActiveSheet()->mergeCells('A2:B2');
|
|
|
|
|
|
|
|
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
|
|
|
|
|
|
|
$actual = 0;
|
|
|
|
foreach ($reloadedSpreadsheet->getWorksheetIterator() as $worksheet) {
|
|
|
|
$actual += count($worksheet->getMergeCells());
|
|
|
|
}
|
|
|
|
|
|
|
|
self::assertSame(1, $actual, "Format $format failed, could not read 1 merged cell");
|
|
|
|
}
|
|
|
|
}
|