compatibilityMode = Functions::getCompatibilityMode();
Functions::setCompatibilityMode(
Functions::COMPATIBILITY_OPENOFFICE
);
}
protected function tearDown(): void
{
parent::tearDown();
Functions::setCompatibilityMode($this->compatibilityMode);
}
public function testWriteSpreadsheet(): void
{
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'aa');
$sheet->setCellValue('B1', 'bb');
$sheet->setCellValue('A2', 'cc');
$sheet->setCellValue('B2', 'dd');
$sheet->getStyle('A1')->getAlignment()->setIndent(2);
$writer = new Ods($spreadsheet);
$content = new Content($writer);
$xml = $content->write();
self::assertStringContainsString(
''
. ''
. ''
. '',
$xml
);
self::assertStringContainsString(
''
. ''
. '' // fo:margin-left is what we're looking for
. ''
. '',
$xml
);
self::assertSame(3, substr_count($xml, 'table:style-name="ce0"'));
self::assertSame(1, substr_count($xml, 'table:style-name="ce1"'));
$spreadsheet->disconnectWorksheets();
}
}