Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Ods, merged cells broken #287

Closed
1 task done
alpha-and-omega opened this issue Dec 10, 2017 · 0 comments
Closed
1 task done

Bug in Ods, merged cells broken #287

alpha-and-omega opened this issue Dec 10, 2017 · 0 comments

Comments

@alpha-and-omega
Copy link

alpha-and-omega commented Dec 10, 2017

This is:

  • a bug report

What is the expected behavior?

Merged cells should work in Ods format

What is the current behavior?

Merged cells do not work in Ods format

What are the steps to reproduce?

Test code provided, creates and tests files in all merge-supported formats, only Ods fails.
This can be added to tests.

<?php

require __DIR__ . '/vendor/autoload.php';
//////////////////////////////////////////////////////////
// example with merged cells:
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', '1');
$spreadsheet->getActiveSheet()->setCellValue('B1', '2');
$spreadsheet->getActiveSheet()->setCellValue('A2', '33');
$spreadsheet->getActiveSheet()->mergeCells('A2:B2');
//////////////////////////////////////////////////////////
// Write in all merge-supported formats:
$Formats = array('Html','Xls','Xlsx','Ods');
foreach( $Formats as $Format)
{
	// create test file:
	$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, $Format);
	$file = "merge.".strtolower($Format);
	$writer->save($file);

	// now test:
	if( 1 != calculate_merged_cells($file,$Format) ) die("Format $Format failed, no merged cells found!\n");
}

function calculate_merged_cells($file,$Format)
{
	$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($Format);
	$spreadsheet = $reader->load($file);
	$n = 0;
	foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
		foreach ($worksheet->getMergeCells() as $cells) {
			var_dump($cells);
			$n++;
		}
	}
	return $n;
}

Which versions of PhpSpreadsheet and PHP are affected?

all including latest development version

Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this issue Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant