Skip to content

How to editing Header? #2528

Open
Open
@MixanM

Description

@MixanM

Hello, I'm facing a problem - I can't read data from the header of my document. I have a table header in it, I tried different methods - an array is returned to me, but when reading data from there, I get a problem, please help.

$source = "uploads/text.docx";
$objReader = \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpWord = $objReader->load($source);
$headers = $section->getHeaders();
$header1 = $headers[1]; // note that the first index is 1 here (not 0)
$elements = $header1->getElements();

/** its dont work*/
$element1 = $elements[0]; // and first index is 0 here normally
// for example manipulating simple text information ($element1 is instance of Text object)
$element1->setText("This is my text addition - old part: " . $element1->getText());
/** its dont work*/
Fatal error: Uncaught Error: Call to undefined method PhpOffice\PhpWord\Element\TextBreak::setText() 

Header into my 'docx' file
image
how do I get the value from the 5th and 6th column ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions