国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#中把多個Word文檔合并為一個文檔的方法

2023-05-18 12:33:10
字體:
來源:轉載
供稿:網友

有時我們需要將多個word文檔合并為一個文檔,下面將給出具體的操作方法和源代碼。

對WORD文檔的合并方式分兩種形式:復制合并和插入合并,即將多個文檔按照先后順序合并到另一個文檔中。具體源代碼如下:

using System;

using System.Collections.Generic;

  using System.Text;

  using Microsoft.Office.Interop.Word;

  using System.Reflection;

  using System.IO;

  using System.Diagnostics;

  namespace Eipsoft.Common

  {

  /// <summary>

  /// Word文檔合并類

  /// </summary>

  public class WordDocumentMerger

  {

  private ApplicationClass objApp = null;

  private Document objDocLast = null;

  private Document objDocBeforeLast = null;

  public WordDocumentMerger()

  {

  objApp = new ApplicationClass();

  }

  #region 打開文件

  private void Open(string tempDoc)

  {

  object objTempDoc = tempDoc;

  object objMissing = System.Reflection.Missing.Value;

  objDocLast = objApp.Documents.Open(

   ref objTempDoc,    //FileName

    ref objMissing,   //ConfirmVersions

    ref objMissing,   //ReadOnly

    ref objMissing,   //AddToRecentFiles

    ref objMissing,   //PasswordDocument

    ref objMissing,   //PasswordTemplate

    ref objMissing,   //Revert

    ref objMissing,   //WritePasswordDocument

    ref objMissing,   //WritePasswordTemplate

    ref objMissing,   //Format

    ref objMissing,   //Enconding

    ref objMissing,   //Visible

    ref objMissing,   //OpenAndRepair

    ref objMissing,  //DocumentDirection

    ref objMissing,  //NoEncodingDialog

    ref objMissing   //XMLTransform

    );

    objDocLast.Activate();

    }

    #endregion

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉定区| 郎溪县| 宁阳县| 丁青县| 安义县| 化州市| 屏东市| 珠海市| 泽库县| 吉木乃县| 凤冈县| 台南县| 石家庄市| 寻乌县| 彭泽县| 黔东| 德格县| 嘉义县| 凤冈县| 罗城| 城步| 云安县| 晋州市| 东台市| 呼图壁县| 黎城县| 芦溪县| 长宁县| 永济市| 阿巴嘎旗| 灌南县| 无为县| 汉沽区| 正宁县| 榆林市| 马龙县| 凤台县| 沂水县| 遂溪县| 钟祥市| 凤冈县|