Python: Is there a way I can add a footnote to word document?

旧街凉风 提交于 2019-12-12 03:18:49

问题


I have tried the following with python-docx:

section = self.document.sections[0]
footer = section._sectPr.footer
footer.text = "I am here"

I couldn't find a clear footer/header directions in docx documentations. Is there a work around to cover this gap?


回答1:


The work around is:

  • Create a document with python-docx.
  • Change the name to 'init.docx'
  • Comment any adding-new-style code
  • Open 'init.docx'
  • Delete everything
  • Save it.
  • Add footnote/Headers to 'init.docx'
  • Change self.document = Document('') to self.document = Document('init.docx').


来源:https://stackoverflow.com/questions/38795791/python-is-there-a-way-i-can-add-a-footnote-to-word-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!