Search code examples
pythonjsondocxpython-docx

Is there any way to add a subheading to a table in python-docx?


Statement: I have tried to generate table from a JSON file and want it to auto numbering the subheading.

Is there any way to makes auto numbering works for a table under a paragraph heading? Should I have to do something with table.style or not?

This is what I want as an output: table.

I want it to auto numbering the table heading to "3.1" below "3 Chapter Three".

Sorry for any grammatical mistakes. Thank you in advance.


Solution

  • styleParagraph = document.add_paragraph("Hello it me")
    styleParagraph.style = 'Heading 1'