C# 设置word中table翻页不隔断

来源:互联网 发布:武汉人工智能公司 编辑:程序博客网 时间:2024/04/27 19:15


C#


 public static object oMissing = System.Reflection.Missing.Value;      

          //设置word中table的属性(设置表分页不隔断)

MsWord.Application wordApp = new MsWord.Application();

wordDoc = wordApp.Documents.Open(“word路径”,
                           ref oMissing, true,
                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                           ref oMissing, ref oMissing, ref oMissing, false, ref oMissing,
                           ref oMissing, ref oMissing, ref oMissing);


                foreach (Table table in wordDoc.Tables) //便利word中的所有表
                {
                   //Microsoft.Office.Core.MsoTriState.msoTrue


                        table.Rows.AllowBreakAcrossPages = -1; //为什么是-1:the integral equivalent of the Boolean True (in VSTO) is -1.

                        //只须设置此项即可。。-1和0表示true。暂未发现false用什么表示
                        table.Rows.HeadingFormat = -1;

                      //VB代码:table.Rows.AllowBreakAcrossPages  = true

                      //                table.Rows.HeadingFormat = true  
                    
                }


原创粉丝点击