Open meetmagdalene opened 9 years ago
Have this question too. My task is to create a custom report. I was thinking to put each report section generation code to a separate class and them add them in a custom order to PHPWord object in the end. Need to let user define the wether each section shall be included in the final report and in which order.
Was planning to create a PhpOffice\PhpWord\Element\Section object for each report section and then append them all to the main object. But it does not seem possible.
Am I missing something? Or is there another way to achieve this?
@ivangretsky with the latest dev-develop version you can sort the sections by passing a callable. Internally it will use uasort to sort the array
I am new to using this PHPWord library and I am liking it so far.
If someone could help me figure this out or confirm for me if this is even possible or not I would greatly appreciate it.
It seems as though the sections need to be created in the order which you want them to appear on the page, but I'm looking for a way to re-ordering them, or better yet, even nesting them within one another.
They appear in the document in the order in which I construct them, which is fine some of the time, but later in my code I may or may not want to change the order of the sections based on some new data in my code. So I want to move the
$pFirstSectionPointer
to before the$pSectionPointer
.How can I do this?
I've tried setting/changing the elementId and other properties of the sections using setters provided in the API to try and change the order, but there is no explanation for each method and none of them seem to do what I am wanting to do.
Here is my stackoverflow with the same question. I didn't get any responses right away so I thought I would add it here too. Feel free to comment on the stackoverflow instead.
http://stackoverflow.com/questions/30223271/nesting-sections-or-reordering-sections-in-phpword