ms-word

Python-docx, how to set cell width in tables?

Python-docx, how to set cell width in tables? Question: How to set cell width in tables?, so far I got: from docx import Document from docx.shared import Cm, Inches document = Document() table = document.add_table(rows=2, cols=2) table.style = ‘TableGrid’ #single lines in all cells table.autofit = False col = table.columns[0] col.width=Inches(0.5) #col.width=Cm(1.0) #col.width=360000 #=1cm document.save(‘test.docx’) …

Total answers: 6

How to return generated file download with Django REST Framework?

How to return generated file download with Django REST Framework? Question: I need to return generated file download as a Django REST Framework response. I tried the following: def retrieve(self, request, *args, **kwargs): template = webodt.ODFTemplate(‘test.odt’) queryset = Pupils.objects.get(id=kwargs[‘pk’]) serializer = StudentSerializer(queryset) context = dict(serializer.data) document = template.render(Context(context)) doc = converter().convert(document, format=’doc’) res = HttpResponse( …

Total answers: 7

How to convert txt file or PDF to Word doc using python?

How to convert txt file or PDF to Word doc using python? Question: Is there a way to convert PDFs (or text files) to Word docs in python? I’m doing some web-scraping for my professor and the original docs are PDFs. I converted all 1,611 of those to text files and now we need to …

Total answers: 6

Removing Paragraph From Cell In Python-Docx

Removing Paragraph From Cell In Python-Docx Question: I am attempting to create a table with a two row header that uses a simple template format for all of the styling. The two row header is required because I have headers that are the same under two primary categories. It appears that the only way to …

Total answers: 2

How to use python-docx to replace text in a Word document and save

How to use python-docx to replace text in a Word document and save Question: The oodocx module mentioned in the same page refers the user to an /examples folder that does not seem to be there. I have read the documentation of python-docx 0.7.2, plus everything I could find in Stackoverflow on the subject, so …

Total answers: 11

How do I extract data from a doc/docx file using Python

How do I extract data from a doc/docx file using Python Question: I know there are similar questions out there, but I couldn’t find something that would answer my prayers. What I need is a way to access certain data from MS-Word files and save it in an XML file. Reading up on python-docx did …

Total answers: 5

Copying code into word document and keeping formatting

Copying code into word document and keeping formatting Question: I need to get my code (Python 2.7 written in the Python IDE) into a word document for my dissertation but I am struggling to find a way of copying it in and keeping the formatting, I’ve tried paste special and had no luck. The only …

Total answers: 2

.doc to pdf using python

.doc to pdf using python Question: I’am tasked with converting tons of .doc files to .pdf. And the only way my supervisor wants me to do this is through MSWord 2010. I know I should be able to automate this with python COM automation. Only problem is I dont know how and where to start. …

Total answers: 14

How can I use Microsoft Word's spelling/grammar checker programmatically?

How can I use Microsoft Word's spelling/grammar checker programmatically? Question: I want to process a medium to large number of text snippets using a spelling/grammar checker to get a rough approximation and ranking of their “quality.” Speed is not really of concern either, so I think the easiest way is to write a script that …

Total answers: 2

How can I create a Word document using Python?

How can I create a Word document using Python? Question: I’d like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client …

Total answers: 5