日期:2014-05-18  浏览次数:20806 次

winform导出Word中分页问题
如题,我做的程序需要导出word,word中画的表格,行数的话会很多页,这个时候怎么加分页,就是共几页第几页这样子

------解决方案--------------------
WORD模板中设置页码
或Footers(wdHeaderFooterPrimary).Range.Text
------解决方案--------------------
C# code
if (WordApp.ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView || WordApp.ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)
                    {
                        WordApp.ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;
                    }
                    WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryFooter;
                                       object objATEntry_Page = "第 X 页 共 Y 页";
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;//设置居中齐
                    object objTrue = true;
                    Range rng = WordApp.Selection.HeaderFooter.Range;
                    WordApp.NormalTemplate.AutoTextEntries.get_Item(ref objATEntry_Page).Insert(rng, ref objTrue);
                    WordApp.Selection.HeaderFooter.Range.InsertBefore(sFooter);
                                        WordApp.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekMainDocument;