ExtraGain

07蓄势,08翱翔
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

往Word2003中写入内容(含图片)

Posted on 2007-12-13 23:08  ExtraGain  阅读(314)  评论(0)    收藏  举报

 

  1using System;
  2using System.Collections.Generic;
  3using System.Text;
  4using Word;
  5using System.Reflection;
  6using System.Runtime.InteropServices;
  7using System.Data;
  8using System.Configuration;
  9using System.IO;
 10
 11namespace CNINSURE.WEB.COMMON
 12{
 13    public class EnDoc
 14    {
 15        //public static void MessageBox(int h, string m, string c, int type)
 16        //{ }
 17        Word.ApplicationClass app = new Word.ApplicationClass();
 18        object optional = Missing.Value;
 19        object visible = true;
 20        object saveChanges = true;
 21        object NOTsaveChanges = false;
 22        object docreadonly = true;
 23        object originalFormat = Missing.Value;
 24        object routeDocument = Missing.Value;
 25        _Document doc = null;
 26        //  FillCtl f=new FillCtl ();
 27
 28        private string dotpath;
 29        public string DotPath
 30        {
 31            get
 32            {
 33                return dotpath;
 34            }

 35            set
 36            {
 37                dotpath = value;
 38            }

 39        }

 40        private string GetData(string str)
 41        {
 42            if (str == null)
 43                str = "";
 44            else
 45                str = str.Trim();
 46            return str;
 47        }

 48
 49        ******打开文件*******
 70
 71        ******写入数据*******
107
108        ******向表格写入数据*******
150
151        *******将图片写入WORd中********
166
167        ******创建表格*******
216
217        ******删除表格*******
233
234        ******文件另存为*******
248
249        ******关闭word*******
274
275        private object[] GetMark()
276        {
277            object j = null;
278            string str = "";
279            object[] result = new object[doc.Bookmarks.Count];
280            for (int i = 1; i <= doc.Bookmarks.Count; i++)
281            {
282                j = (object)i;
283                result[i - 1= doc.Bookmarks.get_Item(ref j).Name;
284                str = str + doc.Bookmarks.get_Item(ref j).Name + ",";
285            }

286            return result;
287        }

288    }

289}

290