Python-Docx Columns

huangapple go评论154阅读模式
英文:

Python-Docx Columns

问题

我正在尝试将一段文本格式化为多列。有两个方面我想实现:

  1. 我正在尝试在一页内创建多个部分。第一段只有一个列布局,而其余段落则以两列文本格式排列。我尝试创建不同的部分,然后添加段落,然后再创建具有两列布局的另一个部分,但没有成功。最后我搞乱了布局。

  2. 当我创建两列布局时,只有在第一列完全填充后,第二列才会填充文本。这意味着,如果文本只足够填充第一列,那么我会得到一个空的第二列,而不是自动调整长度以将其轻松拆分为两列。是否有办法实现这一点?

无论如何,我根据以下建议创建部分和两列布局:
https://stackoverflow.com/questions/30707120/how-to-programatically-implement-columns-in-page-layout-as-of-in-ms-word-using-p

感谢任何帮助。

英文:

I am trying to format a piece of text into columns.
There are two aspects that I am trying to achieve:

  1. I am trying to have multiple sections within a page. The first paragraph to have only one column layout and the rest of the paragraph to be formatted as two column text. I have tried creating different sections, then add paragraph and then create another section with two column layout, but no success. I am ending up messing up layouts.

  2. When I create two column layouts, the second column is getting populated with text only after first column is fully populated. This means, if the text is only long enough to populate first column, I am getting a blank second row, instead of auto adjusting the length to split it into 2 columns easily.Is there a way to achieve that?

In any case, I am creating sections and 2 column lay out as per below suggestion:
https://stackoverflow.com/questions/30707120/how-to-programatically-implement-columns-in-page-layout-as-of-in-ms-word-using-p

Appreciate any help.

答案1

得分: 1

我找到了解决方法 - 需要在列的末尾添加一个分节符。这与按照下面的方式添加新的分节符一样好:

section = document.add_section(WD_SECTION.CONTINUOUS) 
英文:

I found the solution - it needed to add me a section break at the end of columns.
This was just as good as adding a new section as per below:

section = document.add_section(WD_SECTION.CONTINUOUS) 

huangapple
  • 本文由 发表于 2020年1月3日 20:08:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59578385.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定