国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石狮市| 信阳市| 易门县| 白水县| 河曲县| 中超| 卢湾区| 宿州市| 白沙| 县级市| 广河县| 平泉县| 万载县| 宁国市| 澄城县| 庄浪县| 视频| 龙陵县| 正阳县| 甘洛县| 横峰县| 鄢陵县| 霍州市| 奈曼旗| 涪陵区| 巴里| 临朐县| 德令哈市| 射洪县| 庆阳市| 磐安县| 隆回县| 福贡县| 普洱| 兴化市| 淮北市| 手游| 昌图县| 铜梁县| 麦盖提县| 嘉善县|