python docx run断开_如何在python docx中限制行拆分为下一页

基本上,您将在一个页面中保留单独的行,在它们之间Word可以自由地拆分表。Here是VBA中对解决方案的描述,让我复制答案,以防链接在某个时候失效。(对于具有垂直合并单元格的表,可以通过链接找到更复杂的解决方案。)If you need to keep the whole table on a single page, format all the paragraphs except the last on each row with the 'keep with next' attribute. to do that, you might use code like:Dim Tbl As Table, lRow As Long, Rng As Range

With Tbl

lRow = .Rows.Count

Set Rng = ActiveDocument.Range(.Rows(1).Range.Start, .Rows(lRow - 1).Range.End)

.Rows.AllowBreakAcrossPages = False

.Rows.First.HeadingFormat = True

With .Range.ParagraphFormat

.SpaceBeforeAuto = False

.SpaceAfterAuto = False

.WidowControl = True

.KeepWithNext = False

.KeepTogether = False

.PageBreakBefore = False

.WordWrap = True

End With

With Rng.ParagraphFormat

.KeepWithNext = True

.KeepTogether = True

End With

End With

Set Rng = Nothing: Set Tbl = NothingThe line ' .Rows.First.HeadingFormat = True' ensures that, if the table is too long to fit on a whole page, the heading row will appear on the subsequent pages also.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值