Is it possible to set the table column to have different alignment? For example, the first column has alignment to the left but the second column has the alignment to the right. I have checked the document. It seems only table has the alignment attribute, not column. or is it possible to create a table style in word and set the table style like this? But I spent hours in word, still couldn't create such kind of table style. I really appreciate if you can help me resolve the issue. thanks
Ding
are you Solved this question?
No, I haven't. I figured the table style has to be added in the word template, but I couldn't figure out how to add the table style in word.
I have find a mathod ,you can try
cells[a].paragraphs[0].paragraph_format.alignment = WD_TABLE_ALIGNMENT.CENTER
You are awesome. This solved my problem! Thank you very much!
You want to use the docx.enum.text.WD_ALIGN_PARAGRAPH enumeration here rather than docx.enum.table.WD_TABLE_ALIGNMENT. It's the paragraph you're aligning, not the table cell.
Most helpful comment
I have find a mathod ,you can try
cells[a].paragraphs[0].paragraph_format.alignment = WD_TABLE_ALIGNMENT.CENTER