Last active
October 23, 2017 05:53
-
-
Save K4zuki/0f80f657b7c982038c8e0933eb0e30b1 to your computer and use it in GitHub Desktop.
python-docx to change table style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
opens a docx file, replace ALL table style(*) and save on same file | |
mainly for pandoc exported docx file | |
(*) the applying style must be pre-defined in given file | |
Applies MIT License - 2017 K4ZUKI([email protected]) | |
""" | |
import docx # python-docx 0.8.6+ | |
docu = docx.Document("file.docx") | |
for tbl in docu.tables: | |
tbl.style = "Table Grid" | |
docu.save("file.docx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment