Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果可能的话,防止表格在页面上被打断_C#_Ms Word_Openxml - Fatal编程技术网

C# 如果可能的话,防止表格在页面上被打断

C# 如果可能的话,防止表格在页面上被打断,c#,ms-word,openxml,C#,Ms Word,Openxml,我正在使用OpenXML生成包含数千个表的word文档。其中一些表跨越整个页面的长度,这很好,因为无法防止这种情况发生,但是,许多表只包含几行。我可以设置一个属性来防止这些表损坏吗 当一个只有两行的表在两个页面之间拆分时,或者当一个键行是上一页上唯一拆分的行时,看起来很糟糕。我花了大量时间浏览MSDN页面,但运气不好。。。希望以前有人这样做过。这是一种痛苦,但有一种方法可以做到。如果您直接在Word中编辑文档并希望实现此行为,则可以使用段落>换行符和分页符下的“保留下一行”和“保持行在一起”属性

我正在使用OpenXML生成包含数千个表的word文档。其中一些表跨越整个页面的长度,这很好,因为无法防止这种情况发生,但是,许多表只包含几行。我可以设置一个属性来防止这些表损坏吗


当一个只有两行的表在两个页面之间拆分时,或者当一个键行是上一页上唯一拆分的行时,看起来很糟糕。我花了大量时间浏览MSDN页面,但运气不好。。。希望以前有人这样做过。

这是一种痛苦,但有一种方法可以做到。如果您直接在Word中编辑文档并希望实现此行为,则可以使用段落>换行符和分页符下的“保留下一行”和“保持行在一起”属性。基本上,您可以选中该框为表中的每一行启用此属性(从技术上讲,除了最后一行之外,其他所有行都可以启用,不过设置所有行也可以)。因为任何可以在Word中完成的事情都可以使用OOXMLAPI来完成,所以只需要弄清楚就行了。下面是一个代码片段,演示了所需的代码

首先,下面的代码生成了一个Word文档,其中包含一个表,该表将在页面间断开。它首先为表格添加一个简单的样式,然后添加一系列段落以将表格向下推到页面上,最后在底部添加表格

using (WordprocessingDocument document = WordprocessingDocument.Create("TableBreaksAcrossPage.docx", WordprocessingDocumentType.Document))
        {
            MainDocumentPart mainDocumentPart = document.AddMainDocumentPart();

            #region Styles

            Styles styles = new Styles();

            Style style = new Style() { Type = StyleValues.Table, StyleId = "TableGrid" };
            StyleName styleName10 = new StyleName() { Val = "Table Grid" };
            BasedOn basedOn2 = new BasedOn() { Val = "TableNormal" };
            UIPriority uIPriority8 = new UIPriority() { Val = 59 };
            Rsid rsid7 = new Rsid() { Val = "003B7411" };

            StyleParagraphProperties styleParagraphProperties2 = new StyleParagraphProperties();
            SpacingBetweenLines spacingBetweenLines4 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            styleParagraphProperties2.Append(spacingBetweenLines4);

            StyleTableProperties styleTableProperties4 = new StyleTableProperties();
            TableIndentation tableIndentation4 = new TableIndentation() { Width = 0, Type = TableWidthUnitValues.Dxa };

            TableBorders tableBorders2 = new TableBorders();
            TopBorder topBorder2 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            LeftBorder leftBorder2 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            BottomBorder bottomBorder2 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            RightBorder rightBorder2 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideHorizontalBorder insideHorizontalBorder2 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder2 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

            tableBorders2.Append(topBorder2);
            tableBorders2.Append(leftBorder2);
            tableBorders2.Append(bottomBorder2);
            tableBorders2.Append(rightBorder2);
            tableBorders2.Append(insideHorizontalBorder2);
            tableBorders2.Append(insideVerticalBorder2);

            TableCellMarginDefault tableCellMarginDefault4 = new TableCellMarginDefault();
            TopMargin topMargin4 = new TopMargin() { Width = "200", Type = TableWidthUnitValues.Dxa };
            TableCellLeftMargin tableCellLeftMargin4 = new TableCellLeftMargin() { Width = 108, Type = TableWidthValues.Dxa };
            BottomMargin bottomMargin4 = new BottomMargin() { Width = "200", Type = TableWidthUnitValues.Dxa };
            TableCellRightMargin tableCellRightMargin4 = new TableCellRightMargin() { Width = 108, Type = TableWidthValues.Dxa };

            tableCellMarginDefault4.Append(topMargin4);
            tableCellMarginDefault4.Append(tableCellLeftMargin4);
            tableCellMarginDefault4.Append(bottomMargin4);
            tableCellMarginDefault4.Append(tableCellRightMargin4);

            styleTableProperties4.Append(tableIndentation4);
            styleTableProperties4.Append(tableBorders2);
            styleTableProperties4.Append(tableCellMarginDefault4);

            style.Append(styleName10);
            style.Append(basedOn2);
            style.Append(uIPriority8);
            style.Append(rsid7);
            style.Append(styleParagraphProperties2);
            style.Append(styleTableProperties4);

            styles.Append(style);

            StyleDefinitionsPart styleDefinitionsPart = mainDocumentPart.AddNewPart<StyleDefinitionsPart>("Styles");
            styleDefinitionsPart.Styles = styles;

            #endregion

            mainDocumentPart.Document =
            new Document(
                new Body(
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Table(
                        new TableProperties(
                            new TableStyle() { Val = "TableGrid" },
                            new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }),
                        new TableGrid(
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" }),
                        new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 1"))))),
                       new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 2"))))),
                      new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(

                                        ),
                                    new Run(
                                    new Text("Table Row 3"))))),
                     new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4"))))))));
        }
使用(WordprocessingDocument文档=WordprocessingDocument.Create(“TableBreaksCrossPage.docx”,WordprocessingDocumentType.document))
{
MainDocumentPart MainDocumentPart=document.AddMainDocumentPart();
#地域风格
样式=新样式();
Style Style=new Style(){Type=StyleValues.Table,StyleId=“TableGrid”};
StyleName styleName10=newstylename(){Val=“Table Grid”};
BasedOn basedOn2=新的BasedOn(){Val=“TableNormal”};
UIPriority uIPriority8=新UIPriority(){Val=59};
Rsid rsid7=新的Rsid(){Val=“003B7411”};
StyleParagraphProperties styleParagraphProperties2=新的StyleParagraphProperties();
SpacingBetweenLines spacingBetweenLines4=新的SpacingBetweenLines(){After=“0”,Line=“240”,LineRule=LineSpacingRuleValues.Auto};
样式段落属性2.追加(行间间距4);
StyleTableProperties styleTableProperties4=新的StyleTableProperties();
TableIndentation tableIndentation4=newtableindentation(){Width=0,Type=TableWidthUnitValues.Dxa};
TableBorders tableBorders2=新的TableBorders();
TopBorder topBorder2=新TopBorder(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
LeftBorder leftBorder2=新的LeftBorder(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
BottomBottomBorder2=新的bottomBorder2(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
RightBorder rightBorder2=new RightBorder(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
InsideHorizontalBorder insideHorizontalBorder2=新InsideHorizontalBorder(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
InsideverticalOrder InsideverticalOrder2=新建InsideverticalOrder(){Val=BorderValues.Single,Color=“auto”,Size=(UInt32Value)4U,Space=(UInt32Value)0U};
TableBorder2.追加(topBorder2);
tableBorders2.Append(leftBorder2);
tableBorders2.追加(bottomBorder2);
tableBorders2.追加(rightBorder2);
表边界2.附加(内部水平边界2);
tableBorders2.追加(InsideverticalOrder2);
TableCellMarginDefault tableCellMarginDefault4=新的TableCellMarginDefault();
topMargin4=新TopMargin(){Width=“200”,Type=tableWidthUnitValue.Dxa};
TableCellLeftMargin tableCellLeftMargin4=新的TableCellLeftMargin(){Width=108,Type=TableWidthValues.Dxa};
bottomMargin4=新的BottomMargin(){Width=“200”,Type=TableWidthUnitValues.Dxa};
TableCellRightMargin tableCellRightMargin4=新的TableCellRightMargin(){Width=108,Type=TableWidthValues.Dxa};
tableCellMarginDefault4.追加(topMargin4);
tableCellMarginDefault4.Append(tableCellLeftMargin4);
tableCellMarginDefault4.Append(bottomMargin4);
tableCellMarginDefault4.Append(tableCellRightMargin4);
styleTableProperties4.Append(tableIndentation4);
styleTableProperties4.Append(tableBorders2);
styleTableProperties4.Append(tableCellMarginDefault4);
style.Append(styleName10);
style.Append(basedOn2);
追加样式(uIPriority8);
追加样式(rsid7);
style.Append(styleParagraphProperties2);
style.Append(styleTableProperties4);
样式。追加(样式);
StyleDefinitionsPart StyleDefinitionsPart=mainDocumentPart.AddNewPart(“样式”);
styleDefinitionsPart.Styles=样式;
#端区
mainDocumentPart.文档=
新文件(
新机构(
新段落(
新运行(
新文本(“测试”)),
新段落(
新运行(
新文本(“测试”)),
新段落(
新运行(
新文本(“测试”)),
新段落(
using (WordprocessingDocument document = WordprocessingDocument.Create("TableDoesNotBreakAcrossPage.docx", WordprocessingDocumentType.Document))
        {
            MainDocumentPart mainDocumentPart = document.AddMainDocumentPart();

            #region Styles

            Styles styles = new Styles();

            Style style = new Style() { Type = StyleValues.Table, StyleId = "TableGrid" };
            StyleName styleName10 = new StyleName() { Val = "Table Grid" };
            BasedOn basedOn2 = new BasedOn() { Val = "TableNormal" };
            UIPriority uIPriority8 = new UIPriority() { Val = 59 };
            Rsid rsid7 = new Rsid() { Val = "003B7411" };

            StyleParagraphProperties styleParagraphProperties2 = new StyleParagraphProperties();
            SpacingBetweenLines spacingBetweenLines4 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            styleParagraphProperties2.Append(spacingBetweenLines4);

            StyleTableProperties styleTableProperties4 = new StyleTableProperties();
            TableIndentation tableIndentation4 = new TableIndentation() { Width = 0, Type = TableWidthUnitValues.Dxa };

            TableBorders tableBorders2 = new TableBorders();
            TopBorder topBorder2 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            LeftBorder leftBorder2 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            BottomBorder bottomBorder2 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            RightBorder rightBorder2 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideHorizontalBorder insideHorizontalBorder2 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder2 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

            tableBorders2.Append(topBorder2);
            tableBorders2.Append(leftBorder2);
            tableBorders2.Append(bottomBorder2);
            tableBorders2.Append(rightBorder2);
            tableBorders2.Append(insideHorizontalBorder2);
            tableBorders2.Append(insideVerticalBorder2);

            TableCellMarginDefault tableCellMarginDefault4 = new TableCellMarginDefault();
            TopMargin topMargin4 = new TopMargin() { Width = "200", Type = TableWidthUnitValues.Dxa };
            TableCellLeftMargin tableCellLeftMargin4 = new TableCellLeftMargin() { Width = 108, Type = TableWidthValues.Dxa };
            BottomMargin bottomMargin4 = new BottomMargin() { Width = "200", Type = TableWidthUnitValues.Dxa };
            TableCellRightMargin tableCellRightMargin4 = new TableCellRightMargin() { Width = 108, Type = TableWidthValues.Dxa };

            tableCellMarginDefault4.Append(topMargin4);
            tableCellMarginDefault4.Append(tableCellLeftMargin4);
            tableCellMarginDefault4.Append(bottomMargin4);
            tableCellMarginDefault4.Append(tableCellRightMargin4);

            styleTableProperties4.Append(tableIndentation4);
            styleTableProperties4.Append(tableBorders2);
            styleTableProperties4.Append(tableCellMarginDefault4);

            style.Append(styleName10);
            style.Append(basedOn2);
            style.Append(uIPriority8);
            style.Append(rsid7);
            style.Append(styleParagraphProperties2);
            style.Append(styleTableProperties4);

            styles.Append(style);

            StyleDefinitionsPart styleDefinitionsPart = mainDocumentPart.AddNewPart<StyleDefinitionsPart>("Styles");
            styleDefinitionsPart.Styles = styles;

            #endregion

            mainDocumentPart.Document =
            new Document(
                new Body(
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Paragraph(
                        new Run(
                            new Text("Test"))),
                    new Table(
                        new TableProperties(
                            new TableStyle() { Val = "TableGrid" },
                            new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }),
                        new TableGrid(
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" },
                            new GridColumn() { Width = "2000" }),
                        new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 1")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 1"))))),
                       new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 2")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 2"))))),
                      new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 3")))),
                            new TableCell(
                                new Paragraph(
                                    new ParagraphProperties(
                                        new KeepNext(),
                                        new KeepLines()),
                                    new Run(
                                    new Text("Table Row 3"))))),
                     new TableRow(
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4")))),
                            new TableCell(
                                new Paragraph(
                                    new Run(
                                    new Text("Table Row 4"))))))));
        }
new Table(
    new TableProperties(
        new TableStyle() { Val = "TableGrid" },
        new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }),
    new TableGrid(
        new GridColumn() { Width = "2000" },
        new GridColumn() { Width = "2000" },
        new GridColumn() { Width = "2000" },
        new GridColumn() { Width = "2000" }),
    new TableRow(
        new TableRowProperties(
            new CantSplit()),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 1")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 1")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 1")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 1"))))),
   new TableRow(
        new TableRowProperties(
            new CantSplit()),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 2")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 2")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 2")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 2"))))),
  new TableRow(
        new TableRowProperties(
            new CantSplit()),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 3")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 3")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 3")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 3"))))),
 new TableRow(
        new TableRowProperties(
            new CantSplit()),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 4")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 4")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 4")))),
        new TableCell(
            new Paragraph(
                new Run(
                new Text("Table Row 4"))))))));