zoukankan      html  css  js  c++  java
  • 把图片在word中显示

    如下:

      //放入word中
    
                #region word
    
                ThreadPool.QueueUserWorkItem(//使用线程池
                  (P_temp) =>//使用lambda表达式
                  {
                      G_wa = new Word.Application();//创建Word应用程序对象
                      Word.Document P_wd = G_wa.Documents.Add(//建立新文档
                          ref G_missing, ref G_missing, ref G_missing, ref G_missing);
                      Word.Range P_Range = P_wd.Paragraphs[1].Range;//得到段落范围
                      object P_Ranges = P_Range;//创建ojbect对象
                      P_wd.InlineShapes.AddPicture(//向文档中插入图片
                          strChart3, ref G_missing, ref G_missing, ref P_Ranges);
                      P_wd.InlineShapes.AddPicture(//向文档中插入图片
                        strChart2, ref G_missing, ref G_missing, ref P_Ranges);
                      P_wd.InlineShapes.AddPicture(//向文档中插入图片
                        strChart1, ref G_missing, ref G_missing, ref P_Ranges);
                      G_str_path = string.Format(//计算文件保存路径
                          @"{0}\{1}", strPath,
                          DateTime.Now.ToString("yyyy年M月d日h时s分m秒fff毫秒") + ".doc");
                      P_wd.SaveAs(//保存Word文件
                          ref G_str_path,
                          ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                          ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                          ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                          ref G_missing, ref G_missing, ref G_missing);
                      ((Word._Application)G_wa.Application).Quit(//退出应用程序
                          ref G_missing, ref G_missing, ref G_missing);
                      //  this.Dispatcher.Invoke(//开始执行窗体线程
                      //  (MethodInvoker)(() =>//使用lambda表达式
                      //   {
                      // btn_Display.Enabled = true;//启用显示按钮
                      System.Windows.MessageBox.Show("成功创建Word文档!", "提示!");
                      //  }));
                  });
                #endregion
    

      

       private Word.Application G_wa;//定义Word应用程序字段
            private object G_missing = //定义missing字段并赋值
                System.Reflection.Missing.Value;
            private object G_str_path;//定义文件保存路径字段
            private OpenFileDialog G_OpenFileDialog;//定义打开文件对话框字段
            private FolderBrowserDialog G_FolderBrowserDialog;//定义文件夹浏览对话框字段
    

      

    using System.Diagnostics;
    using System.Xml.Linq;
    using System.Threading.Tasks;
    using System.Threading;
    using System.Windows.Forms;
    using Word = Microsoft.Office.Interop.Word;
    using System.IO;
    

      

  • 相关阅读:
    UITableView cell中label自动换行和自定义label自动换行
    IOS Label 自动换行 IOS6和IOS7
    AFNetWorking Request failed: unacceptable content-type: text/html
    IOS程序内发短信 MFMessageComposeViewController
    python--(常用模块-2序列化)
    python--(常用模块-1)
    小学生绞尽脑汁也学不会的python(异常,约束,MD5加密,日志处理)
    小学生绞尽脑汁也学不会的python(反射)
    小学生绞尽脑汁也学不会的python(面对对象-----类与类之间的关系)
    小学生绞尽脑汁也学不会的python(面对对象-----成员)
  • 原文地址:https://www.cnblogs.com/ants_double/p/5359518.html
Copyright © 2011-2022 走看看