We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The function doesn´t get the placeholders from texts in tables.
see below ;-)
public static function extractVariables(string $filename, string $readerName = 'Word2007'): array { $reader = IOFactory::createReader($readerName); $document = $reader->load($filename); $extractedVariables = []; foreach ($document->getSections() as $section) { $concatenatedText = ''; foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { if ($textElement instanceof Text) { $text = $textElement->getText(); $concatenatedText .= $text; } } } else if ($element instanceof Table) { foreach ($element->getRows() as $tableRows) { if ( $tableRows instanceof Row ) { foreach ( $tableRows->getCells() as $tableCells ) { if ( $tableCells instanceof Cell ) { foreach ($tableCells->getElements() as $textrunElement) { if ($textrunElement instanceof TextRun) { foreach ($textrunElement->getElements() as $textElement) { if ($textElement instanceof Text) { $text = $textElement->getText(); $concatenatedText .= $text; } } } } } } } } } } preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $match) { $trimmedMatch = trim($match); $extractedVariables[] = $trimmedMatch; } } } return $extractedVariables; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem? Please describe.
The function doesn´t get the placeholders from texts in tables.
Describe the solution you'd like
see below ;-)
Additional context
The text was updated successfully, but these errors were encountered: