I\'m generating some odt/docx reports via markdown using knitr and pandoc and am now wondering how you\'d go about formating tables. Primarily I\'m interested in adding rule
Using a reference docx file and then python-docx does the job pretty easily :
https://python-docx.readthedocs.io/
First convert your document to docx :
Bash :
pandoc --standalone --data-dir=/path/to/reference/ --output=/tmp/xxx.docx input_file.md
Notes :
/path/to/reference/points to the folder containingreference.docxreference.docxis a file containing the styles you need for docx elements
Then give the tables of your document the style you want to use :
Python :
import docx
document = docx.Document('/tmp/xxx.docx')
for table in document.tables:
table.style = document.styles['custom_style'] # custom_style must exist in your reference.docx file