Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHPWord中通过操作模板删除表_Php_Phpword - Fatal编程技术网

如何在PHPWord中通过操作模板删除表

如何在PHPWord中通过操作模板删除表,php,phpword,Php,Phpword,我正在使用PHPWord开发一些报告生成模块。我从服务器加载了一个模板文档文件。若数据库中有可用的数据,我需要向表中添加动态行。如果数据库中没有数据,我想从加载的模板文件中删除表。是否有任何方法可以使用phpword从加载的模板文件中删除表 您应该能够通过在表周围包装一个模板块并使用cloneBlock函数来实现这一点: if ('there-is-data-to-be-added') { // show the template table normally $template

我正在使用PHPWord开发一些报告生成模块。我从服务器加载了一个模板文档文件。若数据库中有可用的数据,我需要向表中添加动态行。如果数据库中没有数据,我想从加载的模板文件中删除表。是否有任何方法可以使用phpword从加载的模板文件中删除表

您应该能够通过在表周围包装一个模板块并使用cloneBlock函数来实现这一点:

if ('there-is-data-to-be-added')
{
    // show the template table normally
    $templateProcessor->cloneBlock('TABLE-WRAP', 1);

    // clone your row(s) with your data
    $templateProcessor->cloneRow('ROW-TEMPLATE', 10);

    // add your data to the cloned rows...
}
else
{
    // hide the table (note that deleteBlock function doesn't seem to work when you have other template fields inside the table)
    $templateProcess->cloneBlock('TABLE-WRAP', 0);
}