You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking to find a way to properly extract all relevant xml data from an excel file. I found a similar example using PHPWord where xml of a table is being grabbed from a word document like this;
//Create table
$document_with_table = new PhpWord();
$section = $document_with_table->addSection();
$table = $section->addTable();
for ($r = 1; $r <= 8; $r++) {
$table->addRow();
for ($c = 1; $c <= 5; $c++) {
$table->addCell(1750)->addText("Row {$r}, Cell {$c}");
}
}
// Create writer to convert document to xml
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($document_with_table, 'Word2007');
// Get all document xml code
$fullxml = $objWriter->getWriterPart('Document')->write();
// Get only table xml code
$tablexml = preg_replace('/^[\s\S]*(<w:tbl\b.*<\/w:tbl>).*/', '$1', $fullxml);
I'm trying to see if there is a similar approach that can be used with PHPSpreadsheet.
The end goal would be to grab a table from excel file and insert it into word template. I want to see if there is something in PHPSpreadsheet that exists that would mimic:
// Get all document xml code
$fullxml = $objWriter->getWriterPart('Document')->write();
.... in order to retrieve the table information in xml for the purpose of writing it to a word document with PHPWord's template processor as an end goal.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking to find a way to properly extract all relevant xml data from an excel file. I found a similar example using PHPWord where xml of a table is being grabbed from a word document like this;
I'm trying to see if there is a similar approach that can be used with PHPSpreadsheet.
The end goal would be to grab a table from excel file and insert it into word template. I want to see if there is something in PHPSpreadsheet that exists that would mimic:
.... in order to retrieve the table information in xml for the purpose of writing it to a word document with PHPWord's template processor as an end goal.
Beta Was this translation helpful? Give feedback.
All reactions