Skip to content

Commit

Permalink
Merge pull request #1 from swapnilsekhande/swapnilsekhande-patch-1
Browse files Browse the repository at this point in the history
Added Delete Table function
  • Loading branch information
swapnilsekhande authored Dec 6, 2024
2 parents feadceb + 35fffcc commit f009665
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/PhpWord/TemplateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit f009665

Please sign in to comment.