Skip to content

6.0.3 - How does one add a new section to an existing Document #901

Answered by dolanmiu
gjblajian asked this question in Q&A
Discussion options

You must be logged in to vote

Start to think of docx like HTML then it starts making more sense

With HTML, you generally don't write html, then later, "add more <div>s to the html"

A html page is static, just like a Word document

So now, with a declarative style, you would take the data, then do a transform, then add it in sections all in one go

So theres three steps:

  1. Prepare your all data fully
  2. Pass the data into a new function to create a Document
  3. Use Packer to export the document

Because these steps are now succinct with clear boundaries, there will be less bugs and will be easy to test

Adding sections (aka mutating the Document) blurs the lines between data and Word Document. It will be hard to unit test at the …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gjblajian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants