diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index f6fe1d8887..8e57757b91 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -1499,4 +1499,25 @@ public function getTempDocumentFilename(): string { return $this->tempDocumentFilename; } + + /** + * Delete Table + * + * Below function will take $search Parameter as an Input and remove Respective table from format + * + * @param string $search + * return void + */ + public function deleteTable(string $search): void + { + $search = self::ensureMacroCompleted($search); + $tagPos = strpos($this->tempDocumentMainPart, $search); + if ($tagPos) { + $tableStart = $this->findTableStart($tagPos); + $tableEnd = $this->findTableEnd($tagPos); + + // Delete the entire table + $this->tempDocumentMainPart = $this->getSlice(0, $tableStart) . $this->getSlice($tableEnd); + } + } }