PHPWord-将ListItem添加到识别列表项段落样式的表格单元格中
我有一个表格单元格,我想在其中放置一些列表项。下面是我的代码 基本上,我定义了一整套样式,然后添加行和单元格。在其中一个单元格中,我正在添加一个无序列表 注意:如果您想知道为什么我在这里有“exact”参数,PHPWord-将ListItem添加到识别列表项段落样式的表格单元格中,php,ms-word,phpword,Php,Ms Word,Phpword,我有一个表格单元格,我想在其中放置一些列表项。下面是我的代码 基本上,我定义了一整套样式,然后添加行和单元格。在其中一个单元格中,我正在添加一个无序列表 注意:如果您想知道为什么我在这里有“exact”参数,$table->addRow(250,“exact”)这是因为我用过 问题是,在执行类似于$cell->addListItem… 如果我使用$section->而不是$cell-> // Add listitem elements inside table cell $PHPWord->
$table->addRow(250,“exact”)代码>这是因为我用过
问题是,在执行类似于$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
段落样式应用于表格单元格中的列表项,但没有成功
有人知道这样的事情是如何实现的吗?在Cell.php中进行更改
替换:
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) {
$text = utf8_encode($text);
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList, $styleParagraph);
$this->_elementCollection[] = $listItem;
return $listItem;
}
作者:
对我来说,工作是一种魅力
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) {
$text = utf8_encode($text);
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList, $styleParagraph);
$this->_elementCollection[] = $listItem;
return $listItem;
}
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null, $styleParagraph = null) {
$text = utf8_encode($text);
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList, $styleParagraph);
$this->_elementCollection[] = $listItem;
return $listItem;
}