A
A
Andrey2018-08-13 13:24:29
Django
Andrey, 2018-08-13 13:24:29

How to output data from django to word template?

I have a website written in django. It is necessary to output some data to the doc document (it has some template, values ​​from the database itself are substituted), so that later the text can be corrected and printed / saved. How can it be implemented? What to read/watch?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Kuzmichev, 2018-08-13
@alexsandrinia

So google!
The first thing that Google searches for python docx template is the docxtpl library .
Under the hood, the python-docx library known in these circles is used for fiddling with documents + also popular jinja2 for, in fact, templating.
And yes - about .doc , the good old binary proprietary format, most likely, will have to be forgotten. .docx only .
If there is no possibility or desire to translate your template syntax into jinja2, then take python-docx directly and write the logic for replacing tokens in templates with the necessary values ​​from the database yourself.

V
Vampre, 2018-08-17
@Vampre

Here about work with xlsx files directly without special libraries. dosx similar https://otus.ru/events/webopen2/113/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question