Questions tagged [python-docx]

A python library to create, read and write Microsoft Office Word 2007 docx files.

The docx module creates, reads and writes Microsoft Office Word 2007 docx files.

Including the following features:

Creation:

  • Paragraphs
  • Bullets
  • Numbered lists
  • Document properties (author, company, etc)
  • Multiple levels of headings
  • Tables
  • Section and page breaks
  • Images

Modification:

  • Search and replace
  • Extract plain text of document
  • Add and delete items anywhere within the document
  • Change document properties
  • Run xpath queries against particular locations in the document - useful for retrieving data from user-completed templates.

For detailed information and examples, visit the python-docx documentation.

See also the official GitHub homepage.

1026 questions
-1
votes
1 answer

How to add pictures to docx python from URL?

I am having trouble with the Python Docx Library, I have scraped images from a website and I want to add them to docx but I cannot add the images to docx directly, I keep getting an error: File "C:\Python27\lib\site-packages\docx\image\image.py",…
-1
votes
2 answers

Inserting txt file info into docx

I am using python 3.5, python-docx, and TKinter. Is there any way to be able to type a .txt file name into an entry box and have python insert the contents of that .txt file into a specific place in docx? I know how to get information from Entry…
Craig Walker
  • 125
  • 1
  • 9
-1
votes
1 answer

How to write to a open Word Document

I wish to be able to write to an open word document using python-docx. However this throws a IOError: [Errno 13] Permission denied: 'test.docx' which i had kind of suspected due to similar cases in the past, but i would like to be able to alter the…
john hon
  • 93
  • 2
  • 7
-1
votes
1 answer

How to color text to later be put in a docx file?

I want to color a text present in the string and pass the string to another python file so that to put received colored string into a docx file. I tried in this way but it is not working. from termcolor import colored from docx import…
Rejo Varghese
  • 57
  • 1
  • 9
-1
votes
1 answer

insert annotation to a word document by using POI or DOCX4J

I'd like to insert some annotations into work documents by using Java or Python. I tried POI, DOCX4J and python-docx. But unfortunately until now I didn't figure out how to use them to generate annotation in a word document. Any advice would be…
S.SMITH
  • 11
-1
votes
1 answer

Installing Docxfactory in python

I am trying to install the package Docxfactory to use in python. I am pretty new to python and I have had about 50/50 success with installing packages... For this one when I use pip as in pip install docxfactory it says "Could not find a version…
McHenry
  • 201
  • 2
  • 8
-1
votes
2 answers

How can I make table header cells both bold and underline in python?

I am creating a table using python 3.4 and I would like to make the header both bold and underline. The following code will make the header bold: table = document.add_table(rows=1, cols=3) hdr_cells =…
JeffC
  • 103
  • 1
  • 3
  • 6
-1
votes
1 answer

How do I embed a csv file into a Word Document with Python docx

I'm opening a docx file and I want to embed into it a csv file. The csv should be displayed as an icon. How would I set it's ecaxt position in my Word File? My code so far is: from Tkinter import Tk from tkFileDialog import askopenfilename import…
Kyriakos
  • 11
  • 3
-2
votes
2 answers

Why python-docx?

import docx import collections listofnames = list() filename = 'Missing_Assignments.docx' filehandle = docx.Document(filename) studentinfo = filehandle.paragraphs for student in studentinfo: if len(student.text) > 1 or len(student.text) > 20: …
-2
votes
1 answer

AttributeError: 'str' object has no attribute 'add_picture'

I need to insert a picture(png format and named as {number2}.png) in the word(named as {number2}.docx), but it doesn't work and shows this error, someone can help me?enter image description here
Danny
  • 3
  • 2
-2
votes
1 answer

How to get aligment of text?

I use ooxml.doc.Text, and need to know that text is in a center, left, or in right. In Text i have only these functions/values: 'parent', 'ppr', 'reset', 'rpr', 'text', 'value', in this class not have aligment variable. How I can get that?
-2
votes
1 answer

I can't change the font in python-docx

when I input : from docx.enum Import WD_STYLE_TYPE the output is: from docx.enum import WD_STYLE_TYPE ImportError: cannot import name 'WD_STYLE_TYPE' from 'docx.enum' I already had problems installing python-docx that solved
-2
votes
1 answer

Python3 Docx get text between 2 paragraphs

i have .docx files in a directory and i want to get all text between two paragraphs. Example: Foo : The foo is not easy, but we have to do it. We are looking for new things in our ad libitum way of life. Bar : I want to get : The foo is not…
ricardo
  • 82
  • 1
  • 8
-2
votes
1 answer

Use python-docx to batch process many datum and generate reports. But doc file contains previous data file's analysis results

There is a for loop in my code to go through each data file, and codes to analyze the data(plotting graphs), and then add graphs to the doc file. The doc file always contains previous data's analysis results(the graphs), which isn't what i want. I…
Roy_San
  • 3
  • 1
-2
votes
1 answer

how to stop python loop from stacking information

I plan to automate in python something that will create several .docx files using a while loop. Each file will have its own unique name and have some information inside of it. My problem is that when looping, the information I get inside the…
1 2 3
68
69