【问题标题】:c# Interop Word Rows.AllowBreakAcrossPagesc# Interop Word Rows.AllowBreakAcrossPages
【发布时间】:2019-03-08 15:46:12
【问题描述】:

我正在尝试使用 Interop Word 编写表格,但我不想允许跨页中断。所以我使用 Rows.AllowBreakAcrossPages 属性,但它对我不起作用,我不知道问题是什么?

有什么帮助吗?

 Word.Table table = rngDoc.Tables.Add(rngDoc, numFilasNueva, numColumnas);
        table.Rows.AllowBreakAcrossPages = (int)Microsoft.Office.Core.MsoTriState.msoFalse;

【问题讨论】:

  • 是行跨页还是表中断?签出this
  • 嗨@Magnetron,是打破桌子。谢谢你!!!

标签: c# ms-word interop


【解决方案1】:

AllowBreakAcrossPages 属性仅适用于单行。它不能将整个表格保持在一页上。

如果表格需要完整地保留在一页上,可以使用段落格式:KeepWithNext(表格中的最后一段除外)和KeepLinesTogether。 (最好使用样式,而不是直接格式化。)

或者,将表格嵌套在另一个表格中(一行,一列 = 一个单元格),AllowBreakAcrossPages 设置为 False。

或者将表格放在 Frame 或 TextBox 中。

但是,如果表格比一页长,最后两个不会中断到另一页。

【讨论】:

    【解决方案2】:

    我做到了

    table.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
    table.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
    table.Rows.AllowBreakAcrossPages = (int)Microsoft.Office.Core.MsoTriState.msoFalse;
    Word.ParagraphFormat pf = table.Range.ParagraphFormat;
    pf.KeepWithNext = (int)Microsoft.Office.Core.MsoTriState.msoTrue;
    pf.KeepTogether = (int)Microsoft.Office.Core.MsoTriState.msoTrue;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 1970-01-01
      相关资源
      最近更新 更多