Questions tagged [docxtpl]

python module built on top of python-docx to use docx documents as jinja2 templates

python module built on top of to use docx documents as templates

website: https://pypi.org/project/docxtpl/

57 questions
0
votes
1 answer

Using docxtpl library in Python, how to generate complex Word documents from multiple tables of different data?

Using docxtpl library in Python to generate complex Microsoft Word documents from Excel data, is it possible to generate a single document from multiple "contexts" or tables? For example, list1 contains people with data about each person, and list2…
Rycliff
  • 127
  • 1
  • 9
0
votes
0 answers

change specific word page variable in docxtpl template (python)

How I go to next word page in docxtpl? I have template called example.docx. I gave same variables to all pages. I'm going to change variables from specific page with while loop and random. I found some examples with docx module. document =…
0
votes
1 answer

python docxtpl insert two sub documents into one template

I would like to insert two generated sub documents into one template. It partly works, but it seems that there is a bug in docxtpl. The end of my template disappears if I insert my sub document(s). See the following example: The template.docx has…
Thomas
  • 82
  • 10
0
votes
0 answers

Pandas KeyError using the docxtpl library

I am trying to create a program that takes in excel data from a spreadsheet and puts that data into separate word documents. Below is my current code: from docxtpl import DocxTemplate import pandas as pd excel_doc = pd.read_excel("facturen holding…
0
votes
0 answers

How to edit graph values in a word document using python

I have a graph with some values in a word document. Is there any way to change the existing values of that graph using python.? Right now I'm using docx and docxtpl for modifying the word document but I couldn't find any solution to alter the graph…
0
votes
0 answers

expected token ‘end of print statement’, got ‘Size’

I am trying to automate population of word template using python. The library I am using is docxtpl to help me do that. I am getting this expected token ‘end of print statement’ got ‘Size’ error and don’t know where to look for help. It’s some sort…
0
votes
0 answers

How do I write N₂O to word by docxtpl

workdir = 'E:/tanlian-workspace/remall-business-center' tpl = DocxTemplate(f'{workdir}/docs/temp/temp.docx') context = {'name': 'N₂O'} jinja_env = jinja2.Environment(autoescape=True) tpl.render(context,…
0
votes
0 answers

Is there any better way to create bulk Word documents using python by taking data from Excel?

I want to create bulk Word documents from Excel. There is a pre-defined Word template. I need to put names, acc numbers, etc. from Excel in the word documents. Any idea how? I tried a way by looking at a Youtuber and use Docxtpl but end up in…
0
votes
0 answers

Using Python and Docxtpl to automate report: Purposefully missing images is breaking / halting code

Context I have been working for some time on creating a Python Script that uses the docxtpl package (and Jinja2 for managing tags and templates) to automate creation of MS Word reports. My script (see below) is located in abase directory, along with…
John W
  • 1
0
votes
1 answer

Python Jinja2 - Passing multiple variables using the render method

I am trying to write a function that would generate a word file using multiple variables but I'm having a bit of trouble actually pushing the variables into the word file. def DocGenerator (var1, var2, var3...var20) : doc =…
MoMo
  • 13
  • 3
0
votes
0 answers

Docxtpl - add image from binary value

After loading a docxtpl object, adding image from storage path works fine. But is there a way to add from binary value of an image directly to document ? In the framework I use, images are stored in separate table as binary values. Looking for a way…
NinjaBat
  • 370
  • 4
  • 20
0
votes
1 answer

Python printing & (and) character in MS word through python

I am generating MS word files through Python using docxtpl. I am trying to import the Humanities&Social Sciences text into an MS word file. But, I see Humanities Sciences printed in MS word. I tried these combinations, but they did not work:…
Mainland
  • 4,110
  • 3
  • 25
  • 56
0
votes
1 answer

Can I change word font color using python?

I am using docxtpl to dealing with word template. Using RichText can change the new add font, but I want to change font color that exist in word template. Is there any solution?
CYL
  • 1
0
votes
1 answer

In Python, how to solve 'ModuleNotFoundError: No module named 'docxtpl'

I have installed pip install docxtpl with no errors. Previously I have ran programs with no erros. But I am getting this weird error of no module found. Don't know what to do? Installation: Nomodule error on CMD prompt when ran a py scrript
Mainland
  • 4,110
  • 3
  • 25
  • 56
0
votes
1 answer

copy data table from csv file to word document in table using python and jinja2

Anyone can help me for my code, I am using existing Word Template to extract from csv file to write in table inside template word, and using python libraries such as: docxtpl, pandas, csv user.dst device.ip count(user.dst) user1 …