public static function testDoc()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(array(
'orientation' => 'landscape',
'marginLeft' => 600,
'marginRight' => 600,
'marginTop' => 600,
'marginBottom' => 600,
));
$section->addTextBreak(1); // перенос строки
$section->addText("Table with colspan and rowspan");
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center');
$cellRowContinue = array('vMerge' => 'continue');
$cellColSpan2 = array('gridSpan' => 2, 'valign' => 'center');
$cellColSpan3 = array('gridSpan' => 3, 'valign' => 'center');
$cellHCentered = array('align' => 'center');
$cellVCentered = array('valign' => 'center');
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
$table = $section->addTable('Colspan Rowspan');
$table->addRow(null, array('tblHeader' => true));
$table->addCell(2000, $cellVCentered)->addText('A', array('bold' => true), $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('B', array('bold' => true), $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('C', array('bold' => true), $cellHCentered);
$table->addCell(2000, $cellColSpan2)->addText('D', array('bold' => true), $cellHCentered);
$table->addRow();
$table->addCell(2000, $cellColSpan3)->addText(' colspan=3 '
. '(need enough columns under -- one diff from html)', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('E', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('F', null, $cellHCentered);
$table->addRow();
$table->addCell(2000, $cellRowSpan)->addText('rowspan=2 '
. '(need one null cell under)', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellRowSpan)->addText('rowspan=3 '
. '(nedd 2 null celss under)', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addRow();
$table->addCell(null, $cellRowContinue); // 1 пустая в колонке 1
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(null, $cellRowContinue); // 1 пустая в колонке 3
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addRow();
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(null, $cellRowContinue); // 2 пустая в колонке 3
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addRow();
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('Т', null, $cellHCentered);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
DowloadHeader::dowloadByExtention('example22.docx'); // rusphp lib function
$objWriter->save('php://output');
}