使用C#實(shí)現(xiàn)在word中插入頁眉頁腳的方法
針對Word的操作是很多程序都具備的功能,本文即以實(shí)例展示使用C#實(shí)現(xiàn)在word中插入頁眉頁腳的方法,供大家參考借鑒,具體方法如下:
一、插入頁腳的方法:
public void InsertFooter(string footer)
{
if (ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView ||
ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)
{
ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;
}
ActiveWindow.View.SeekView = WdSeekView.wdSeekCurrentPageFooter;
this.Application.Selection.HeaderFooter.LinkToPrevious = false;
this.Application.Selection.HeaderFooter.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
ActiveWindow.ActivePane.Selection.InsertAfter(footer);
//跳出頁眉頁腳設(shè)置
ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
}
二、msdn上的方法:
foreach (Word.Section wordSection in this.Application.ActiveDocument.Sections)
{
Word.Range footerRange = wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
footerRange.Font.ColorIndex = Word.WdColorIndex.wdDarkRed;
footerRange.Font.Size = 20;
footerRange.Text = "頁腳 頁腳";
}
foreach (Word.Section section in this.Application.ActiveDocument.Sections)
{
Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
}
希望本文實(shí)例能夠?qū)Υ蠹业腃#程序設(shè)計(jì)起到一定的幫助作用。
- C# WORD操作實(shí)現(xiàn)代碼
- C#實(shí)現(xiàn)通過模板自動(dòng)創(chuàng)建Word文檔的方法
- C# Word 類庫的深入理解
- asp.net(c#)下讀取word文檔的方法小結(jié)
- 比較全的一個(gè)C#操作word文檔示例
- 使用c#在word文檔中創(chuàng)建表格的方法詳解
- c#開發(fā)word批量轉(zhuǎn)pdf源碼分享
- C#采用OpenXml實(shí)現(xiàn)給word文檔添加文字
- C#采用OpenXml給word里面插入圖片
- C#實(shí)現(xiàn)合并多個(gè)word文檔的方法
- C#獲取Word文檔中所有表格的實(shí)現(xiàn)代碼分享
- C#操作word的方法示例
相關(guān)文章
C# DataTable與Model互轉(zhuǎn)的示例代碼
這篇文章主要介紹了C#DataTable與Model互轉(zhuǎn)的示例代碼,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下2020-12-12
Unity3D基于陀螺儀實(shí)現(xiàn)VR相機(jī)功能
這篇文章主要為大家詳細(xì)介紹了Unity3D基于陀螺儀實(shí)現(xiàn)VR相機(jī)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-04-04
C#調(diào)用Polly庫實(shí)現(xiàn)捕捉異常處理的操作代碼
Polly 是一個(gè) .NET 彈性和瞬態(tài)故障處理庫,允許開發(fā)人員以 Fluent 和線程安全的方式來實(shí)現(xiàn)重試、斷路、超時(shí)、隔離和回退策略,本文給大家介紹了C#調(diào)用Polly庫實(shí)現(xiàn)捕捉異常處理操作,文中有詳細(xì)的代碼示例供大家參考,需要的朋友可以參考下2024-08-08
C# listview添加combobox到單元格的實(shí)現(xiàn)代碼
從別處轉(zhuǎn)來的,自己進(jìn)行了一些小的修改,還不錯(cuò),你自己先拖一個(gè)ListView1和一個(gè)ComboBox1,需要的朋友可以參考下2014-06-06
C#調(diào)用VB進(jìn)行簡繁轉(zhuǎn)換的方法
這篇文章主要介紹了C#調(diào)用VB進(jìn)行簡繁轉(zhuǎn)換的方法,通過調(diào)用VB的動(dòng)態(tài)鏈接庫實(shí)現(xiàn)繁簡轉(zhuǎn)換的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-02-02
Winform圓形環(huán)繞的Loading動(dòng)畫實(shí)現(xiàn)代碼
這篇文章主要介紹了Winform圓形環(huán)繞的Loading動(dòng)畫實(shí)現(xiàn)代碼,有需要的朋友可以參考一下2014-01-01

