• 使用C#在word中插入页眉页脚


     //插入页脚

    1. public void InsertFooter(string footer)  
    2. {  
    3.     if (ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView ||  
    4.         ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)  
    5.     {  
    6.         ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;  
    7.     }  
    8.   
    9.     ActiveWindow.View.SeekView = WdSeekView.wdSeekCurrentPageFooter;  
    10.     this.Application.Selection.HeaderFooter.LinkToPrevious = false;  
    11.     this.Application.Selection.HeaderFooter.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;  
    12.     ActiveWindow.ActivePane.Selection.InsertAfter(footer);  
    13.   
    14.     //跳出页眉页脚设置  
    15.     ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;  
    16.   
    17. }  


     

    msdn上的方法

      1. foreach (Word.Section wordSection in this.Application.ActiveDocument.Sections)  
      2.            {  
      3.                Word.Range footerRange = wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;  
      4.                footerRange.Font.ColorIndex = Word.WdColorIndex.wdDarkRed;  
      5.                footerRange.Font.Size = 20;  
      6.                footerRange.Text = "页脚 页脚";  
      7.            }  
      8.   
      9.            foreach (Word.Section section in this.Application.ActiveDocument.Sections)  
      10.            {  
      11.                Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;  
      12.                headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);  
      13.                headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;  
      14.            } 
  • 相关阅读:
    save html to local
    Django REST framework¶
    a colorful termial output for phantomjs porting from casperjs
    jespern / djangopiston / wiki / Documentation — Bitbucket
    PyKHTML, a Python interface to KHTML
    phantomjs/examples/echoToFile.js at master · ariya/phantomjs
    Scraping multiple sites in parallel and memory consumption Google Groups
    jQuery Arrays | Create, Add To, Remove From and Compare
    They're hiring based on New Brunswick, NJ, USA
    FudanNLP  java based
  • 原文地址:https://www.cnblogs.com/rr163/p/3922349.html
Copyright © 2020-2023  润新知