Python Forum
Span columns with docxTemplate python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Span columns with docxTemplate python
#1
I'm having trouble trying to fill in a table row by row using DocxTemplate. I'm only confused on how the template should look like.

This is my python code:

from docxtpl import Docxtemplate

doc = DocxTemplate("Template.docx")
context = {}
table_info = [{start: "A", end: "C"}, {start: "B", end: "C"}, {start:"F", end:"L"}, {start:"B", end:"R"}]
context["table_info"] = table_info

doc.render(context)
doc.save("Finish.docx")
I want the final result to be in a table like this:

| start | end |
|  A    | C   |
|  B    | C   |
|  F    | L   |
|  B    | R   |
Would anyone be willing to show me how I can accomplish this? I saw this example: https://github.com/elapouya/python-docx-...e_tpl.docx but I wasn't able to wrap my head around what I'm trying to do. Thanks in advance!
Reply


Messages In This Thread
Span columns with docxTemplate python - by jimmeh - May-28-2019, 03:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Here what is the meaning of span=(1,2) ,match='1'? srisrinu 1 2,121 Apr-27-2020, 10:22 AM
Last Post: anbu23
  iterating a span of a list Skaperen 5 3,063 Dec-29-2019, 08:15 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020