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;
    

      

  • 相关阅读:
    JS === 飞机吐子弹
    React === 几个小问题
    CSS === P标签加了定位,里面文字的问题
    css边框的一些属性
    Spring整合quart初识
    Jenkins部署报weblogic.deploy.api.tools.deployer.DeployerException: Java heap space
    js跳转新窗口
    Idea中运行项目时出现:未结束的字符串解决方案
    Idea中类上有叉的解决方法
    清除eclipse,STS workspace历史记录
  • 原文地址:https://www.cnblogs.com/ants_double/p/5359518.html
Copyright © 2011-2022 走看看