我有一个表格单元格,我想在其中放置一些列表项。下面是我的代码。
基本上,我定义了一大堆样式,然后添加行和单元格。在其中一个单元格内,我添加了一个无序列表。
注意:如果您想知道为什么我在此处使用“exact”参数,$table->addRow(250, "exact");
那是因为我已使用此修复程序来控制表格行高。
// Table
$styleTable = array( 'borderSize' => 7,
'cellMarginTop' => 0,
'cellMarginLeft' => 100,
'valign' => 'center',
'spaceAfter' => 0
);
$styleCell = array( 'spaceAfter' => 0
);
$cellTextStyle = array( 'bold' => false,
'size' => 10,
'name' => 'Calibri'
);
$cellTextStyleBold = array( 'bold' => true,
'size' => 10,
'name' => 'Calibri'
);
$listStyleText = array( 'spaceAfter' => 0,
'spaceBefore' => 0,
'spacing' => 0,
'size' => 10
);
$listStyle = array( 'spaceAfter' => 0,
'spaceBefore' => 0,
'spacing' => 0
);
$listStyleParagraph = array( 'spaceAfter' => 0,
'spaceBefore' => 0,
'spacing' => 0
);
$PHPWord->addTableStyle('myTable', $styleTable);
$table = $section->addTable('myTable');
$table->addRow(250, "exact");
$table->addCell(5760, $styleCell)->addText('Type:', $cellTextStyleBold);
$table->addCell(5760, $styleCell)->addText('Kazvin', $cellTextStyle);
$table->addRow(250, "null");
$table->addCell(5760, $styleCell)->addText('Description:', $cellTextStyleBold);
$cell = $table->addCell(5760, $styleCell);
// Add listitem elements inside table cell
$PHPWord->addParagraphStyle('listStyle', array('spaceAfter'=>0));
$cell->addListItem('100% wool pile on a cotton foundation', 0, null, null, 'listStyle');
$cell->addListItem('Semi-open ivory field', 0, null, null, 'listStyle');
$cell->addListItem('Coral and powder blue floral medallion', 0, null, null, 'listStyle');
$cell->addListItem('Formal coral, powder blue and ivory border', 0, null, null, 'listStyle');
问题是列表项段落样式在做类似的事情时没有被使用$cell->addListItem....
如果我要使用$section->
而不是$cell->
// Add listitem elements inside table cell
$PHPWord->addParagraphStyle('listStyle', array('spaceAfter'=>0));
$section->addListItem('100% wool pile on a cotton foundation', 0, null, null, 'listStyle');
$section->addListItem('Semi-open ivory field', 0, null, null, 'listStyle');
$section->addListItem('Coral and powder blue floral medallion', 0, null, null, 'listStyle');
$section->addListItem('Formal coral, powder blue and ivory border', 0, null, null, 'listStyle');
然后'spaceAfter' => 0
工作正常。但是,无序列表出现在表格单元格之外。
我已经尝试了几天试图找到一种方法将'spaceAfter' => 0
段落样式应用于表格单元格内的列表项,但没有运气。
有谁知道如何完成这样的事情?