2016-03-23 40 views
0

这几天我从PHP演示开始。我加载演示文稿并尝试从单元格中删除值。但是没有清除细胞的功能。我刚发现addText()createText()如何通过PhpPresentation从表格中的单元格中删除文本?

public function modTable($slide = null){ 
     $shapes = $slide->getShapeCollection(); 

     foreach($shapes as $shape){ 
      if(get_class($shape) == "PhpOffice\\PhpPresentation\\Shape\\Table") { 
       if($shape->getName()){ 
        $shape->getRow(1)->getCell(0)->createTextRun("-TEST1-"); 
        $shape->getRow(1)->getCell(0)->getParagraph(0)->createText("-TEST2-"); 

       } 
      } 
     } 
} 

回答

1

这个工作对我来说: $shape->getRow(1)->getCell(0)->setParagraphs(array(new Paragraph()));

如果你有一个更好的解决方案,随意添加评论。

相关问题