Skip to content

Commit f009665

Browse files
Merge pull request #1 from swapnilsekhande/swapnilsekhande-patch-1
Added Delete Table function
2 parents feadceb + 35fffcc commit f009665

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,4 +1499,25 @@ public function getTempDocumentFilename(): string
14991499
{
15001500
return $this->tempDocumentFilename;
15011501
}
1502+
1503+
/**
1504+
* Delete Table
1505+
*
1506+
* Below function will take $search Parameter as an Input and remove Respective table from format
1507+
*
1508+
* @param string $search
1509+
* return void
1510+
*/
1511+
public function deleteTable(string $search): void
1512+
{
1513+
$search = self::ensureMacroCompleted($search);
1514+
$tagPos = strpos($this->tempDocumentMainPart, $search);
1515+
if ($tagPos) {
1516+
$tableStart = $this->findTableStart($tagPos);
1517+
$tableEnd = $this->findTableEnd($tagPos);
1518+
1519+
// Delete the entire table
1520+
$this->tempDocumentMainPart = $this->getSlice(0, $tableStart) . $this->getSlice($tableEnd);
1521+
}
1522+
}
15021523
}

0 commit comments

Comments
 (0)