Ejemplo n.º 1
0
        private void save()
        {
            this.Enabled = false;


            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\307\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;//word模板路径

            OrignFile = "\\baseDB\\商标书式\\5 补证撤三出具证明\\07 撤销成为商品服务通用名称注册商标申请书.dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\307\\" + a0.Text + "\\" + a0.Text + ".docx";

            object[] MyBM = new object[12]; //创建一个书签数组

            for (int i = 0; i < 12; i++)    //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }



            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text  = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text  = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text  = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text  = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text  = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text  = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text  = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text  = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text  = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text  = a10.Text;
            doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = a11.Text;
            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a12.Text;
            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 文件保存
 /// </summary>
 /// <param name="filename"></param>
 public void SaveToWord(object filename)
 {
     //文件保存
     oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
     oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
     oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// A function that merges Microsoft Word Documents that uses a template specified by the user
        /// </summary>
        /// <param name="filesToMerge">An array of files that we want to merge</param>
        /// <param name="outputFilename">The filename of the merged document</param>
        /// <param name="insertPageBreaks">Set to true if you want to have page breaks inserted after each document</param>
        /// <param name="documentTemplate">The word document you want to use to serve as the template</param>
        private void Merge(string[] filesToMerge, string outputFilename, bool insertPageBreaks, string documentTemplate)
        {
            object defaultTemplate = documentTemplate;
            object missing         = System.Type.Missing;
            object pageBreak       = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            object outputFile      = outputFilename;

            // Create  a new Word application
            Microsoft.Office.Interop.Word._Application wordApplication = new Microsoft.Office.Interop.Word.Application();
            if (filesToMerge.Count() == 1)
            {
                pageBreak = false;
            }
            try
            {
                // Create a new file based on our template
                Microsoft.Office.Interop.Word._Document wordDocument = wordApplication.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing);

                // Make a Word selection object.
                Microsoft.Office.Interop.Word.Selection selection = wordApplication.Selection;

                int index = 0;

                // Loop thru each of the Word documents
                foreach (string file in filesToMerge)
                {
                    // Insert the files to our template
                    selection.InsertFile(file, ref missing, ref missing, ref missing, ref missing);

                    //Do we want page breaks added after each documents?
                    if (insertPageBreaks && index != filesToMerge.Count() - 1)
                    {
                        selection.InsertBreak(ref pageBreak);
                    }

                    index++;
                }

                // Save the document to it's output file.
                wordDocument.SaveAs(ref outputFile, ref missing, ref missing, ref missing, ref missing,
                                    ref missing, ref missing, ref missing, ref missing, ref missing,
                                    ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

                // Clean up!
                wordDocument.Close(ref missing, ref missing, ref missing);
                wordDocument = null;
            }
            catch (Exception ex)
            {
                //I didn't include a default error handler so i'm just throwing the error
                throw ex;
            }
            finally
            {
                // Finally, Close our Word application
                wordApplication.Quit(ref missing, ref missing, ref missing);
            }
        }
Ejemplo n.º 4
0
        private void WriteWord(string filepath, string path, string content)
        {
            _app = new Microsoft.Office.Interop.Word.Application();
            _doc = _app.Documents.Open(filepath);

            _doc.Paragraphs.Last.Range.Font.Name = "新明細體";
            _doc.Paragraphs.Last.Range.ParagraphFormat.AddSpaceBetweenFarEastAndDigit = 0;
            _doc.Paragraphs.Last.Range.Text = content;


            Object Nothing     = System.Reflection.Missing.Value;
            object objWordName = path;

            _doc.SaveAs(ref objWordName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            CloseDoc();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 导出word功能
        /// </summary>
        /// <param name="sender">事件对象</param>
        /// <param name="e">事件参数</param>
        private void t_tsb_ExportWord_Click(object sender, RoutedEventArgs e)
        {
            object oMissing = System.Reflection.Missing.Value;

            //创建一个Word应用程序实例
            Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
            //设置为不可见
            oWord.Visible = false;
            //模板文件地址,这里假设在X盘根目录
            object oTemplate = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Template\\Template.doc";

            //以模板为基础生成文档
            Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
            //声明书签数组
            object[] oBookMark = new object[4];
            //赋值书签名
            oBookMark[0] = "Company_Name";
            oBookMark[1] = "Tel";
            oBookMark[2] = "Email";
            oBookMark[3] = "Fax";
            //赋值任意数据到书签的位置
            oDoc.Bookmarks.get_Item(ref oBookMark[0]).Range.Text = PTBQuotation.Company_Name;
            oDoc.Bookmarks.get_Item(ref oBookMark[1]).Range.Text = PTBQuotation.Tel;
            oDoc.Bookmarks.get_Item(ref oBookMark[2]).Range.Text = PTBQuotation.Email;
            oDoc.Bookmarks.get_Item(ref oBookMark[3]).Range.Text = PTBQuotation.Fax;
            //弹出保存文件对话框,保存生成的Word
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter     = "Word Document(*.doc)|*.doc";
            sfd.DefaultExt = "Word Document(*.doc)|*.doc";
            if (sfd.ShowDialog() == true)
            {
                object filename = sfd.FileName;

                oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing);
                oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                //关闭word
                oWord.Quit(ref oMissing, ref oMissing, ref oMissing);

                System.Diagnostics.Process.Start(sfd.FileName);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 预览Word
        /// </summary>
        public string PreviewWord(string physicalPath, string url, string scode)
        {
            Microsoft.Office.Interop.Word._Application application = null;
            Microsoft.Office.Interop.Word._Document    doc         = null;
            application = new Microsoft.Office.Interop.Word.Application();
            object missing    = Type.Missing;
            object trueObject = true;

            application.Visible       = false;
            application.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
            doc = application.Documents.Open(physicalPath, missing, trueObject, missing, missing, missing,
                                             missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
            //Save Excel to Html
            object format     = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
            string htmlName   = scode + ".html";//Path.GetFileNameWithoutExtension(physicalPath)
            String outputFile = Path.GetDirectoryName(physicalPath) + "\\" + htmlName;

            doc.SaveAs(outputFile, format, missing, missing, missing,
                       missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing,
                       missing, missing, missing, missing);
            doc.Close();
            application.Quit();
            return(Path.GetDirectoryName(Server.UrlDecode(url)) + "\\" + htmlName);
        }
Ejemplo n.º 7
0
        public static void titreCongé(string raison, string spécialité, string wilaya, string RC, string matricule_fiscal, string date, string gérant, string employé, string poste, string début, string fin, string chemin, string chemin1)
        {
            Microsoft.Office.Interop.Word.Application _ApplicationWord = new Microsoft.Office.Interop.Word.Application();
            _ApplicationWord.Visible = false;
            string path      = chemin1 + "\\Modeles\\REF-TITRE DE CONGES.docx";
            object oFileName = (object)@path;
            object Faux      = (object)false;
            object Vrai      = (object)true;
            object M         = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word._Document _MonDocument = _ApplicationWord.Documents.Add(ref oFileName, ref Faux, ref M, ref Vrai);

            object Nom   = (object)"Logo";
            object Nom1  = (object)"Raison";
            object Nom2  = (object)"Spécialité";
            object Nom3  = (object)"Adresse";
            object Nom4  = (object)"Rc_MatriculeFiscal";
            object Nom5  = (object)"Gérant";
            object Nom6  = (object)"Raison1";
            object Nom7  = (object)"Employé";
            object Nom8  = (object)"Poste";
            object Nom9  = (object)"Date1";
            object Nom10 = (object)"Date2";
            object Nom11 = (object)"Gérant1";
            object Nom12 = (object)"Raison2";
            object Nom13 = (object)"nbr_jours";
            object Nom14 = (object)"Début";
            object Nom15 = (object)"Fin";
            object Nom16 = (object)"Fin1";



            Microsoft.Office.Interop.Word.Bookmark    _MonSignet;
            Microsoft.Office.Interop.Word.Range       _MonRange;
            Microsoft.Office.Interop.Word.InlineShape _MonImage;



            //récupére la liste de signets
            Microsoft.Office.Interop.Word.Bookmarks _MesSignets = _MonDocument.Bookmarks;

            if (_MesSignets.Exists("Logo"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonImage = _MonRange.InlineShapes.AddPicture(@chemin1 + "\\logo.png", ref Faux, ref Vrai, ref M);
            }
            if (_MesSignets.Exists("Raison"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom1);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("Spécialité"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom2);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(spécialité);
            }
            if (_MesSignets.Exists("Adresse"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom3);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya + "/Algérie ");
            }
            if (_MesSignets.Exists("Rc_MatriculeFiscal"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom4);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(RC + "/" + matricule_fiscal);
            }
            if (_MesSignets.Exists("Gérant"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom5);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant);
            }
            if (_MesSignets.Exists("Raison1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom6);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("Employé"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom7);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(employé);
            }
            if (_MesSignets.Exists("Poste"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom8);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(poste);
            }
            if (_MesSignets.Exists("Date1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom9);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date);
            }
            if (_MesSignets.Exists("Date2"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom10);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter("le " + date);
            }
            if (_MesSignets.Exists("Gérant1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom11);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant);
            }
            if (_MesSignets.Exists("Raison2"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom12);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("nbr_jours"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom13);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                DateTime debut      = Convert.ToDateTime(début);
                DateTime end        = Convert.ToDateTime(fin);
                TimeSpan difference = end.Date - debut.Date;
                string   nbj        = Convert.ToString(difference.Days);
                _MonRange.InsertAfter(nbj + " ");
            }
            if (_MesSignets.Exists("Début"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom14);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + début + " ");
            }
            if (_MesSignets.Exists("Fin"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom15);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + fin + " ");
            }
            if (_MesSignets.Exists("Fin1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom16);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + fin);
            }

            oFileName = @chemin;
            _MonDocument.SaveAs(ref oFileName, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M);

            _MonDocument.Close(ref M, ref M, ref M);
            _ApplicationWord.Application.Quit(ref M, ref M, ref M);
        }
Ejemplo n.º 8
0
        private void save()
        {
            this.Enabled = true;
            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\7\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;//word模板路径

            OrignFile = "\\baseDB\\商标书式\\7 评审复审\\8商标评审代理委托书\\商标评审代理委托书(样式).dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\7\\" + a0.Text + "\\" + a0.Text + ".docx";

            object[] MyBM = new object[21]; //创建一个书签数组

            for (int i = 0; i < 12; i++)    //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }
            MyBM[12] = "a13_1";
            MyBM[13] = "a13_2";
            MyBM[14] = "a13_3";
            MyBM[15] = "a13_4";
            MyBM[16] = "a13_5";
            MyBM[17] = "a14";
            MyBM[18] = "a15_1";
            MyBM[19] = "a15_2";
            MyBM[20] = "a15_3";
            //  MyBM[21] = "a16";

            /*      驳回商标注册申请复审案
             * 商标不予注册复审案
             * 撤销注册商标复审案
             * 注册商标无效宣告案
             * 注册商标无效宣告复审案*/

            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text  = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text  = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text  = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text  = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text  = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text  = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text  = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text  = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text  = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text  = a10.Text;
            doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = a11.Text;
            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a12.Text;
            if (a13.Text == "驳回商标注册申请复审案")
            {
                doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = "✔";
            }
            if (a13.Text == "商标不予注册复审案")
            {
                doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = "✔";
            }
            if (a13.Text == "撤销注册商标复审案")
            {
                doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = "✔";
            }
            if (a13.Text == "注册商标无效宣告案")
            {
                doc.Bookmarks.get_Item(ref MyBM[15]).Range.Text = "✔";
            }
            if (a13.Text == "注册商标无效宣告复审案")
            {
                doc.Bookmarks.get_Item(ref MyBM[16]).Range.Text = "✔";
            }
            doc.Bookmarks.get_Item(ref MyBM[17]).Range.Text = a14.Text;
            doc.Bookmarks.get_Item(ref MyBM[18]).Range.Text = a15_1.Text;
            doc.Bookmarks.get_Item(ref MyBM[19]).Range.Text = a15_2.Text;
            doc.Bookmarks.get_Item(ref MyBM[20]).Range.Text = a15_3.Text;
            //  doc.Bookmarks.get_Item(ref MyBM[21]).Range.Text = a16.Text;
            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 实现导出word
        /// </summary>
        /// <param name="Data">要存储的数据</param>
        /// <param name="NewFileAddress">目的文件绝对路径。eg:J:////4.1.dot</param>
        /// <param name="TemplateAddress"></param>
        /// <returns></returns>
        public static int StoreWord(string name, int banbenhao, Data[] data, int cuowuleixingshumu, int dengji, string NewFileAddress, string TemplateAddress)
        {
            object oMissing = System.Reflection.Missing.Value;

            //创建一个Word应用程序实例
            Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
            //设置为不可见
            oWord.Visible = false;
            //模板文件地址,这里假设在X盘根目录
            //       object oTemplate = "J://学习//大三下//软件体系结构和设计模式//code//11.dot";
            object oTemplate = TemplateAddress;

            //以模板为基础生成文档
            Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
            //声明书签数组
            object[] oBookMark = new object[11];
            //赋值书签名
            oBookMark[0]  = "wenjianming";
            oBookMark[1]  = "banbenhao";
            oBookMark[2]  = "wentidengji";
            oBookMark[3]  = "weizhi";
            oBookMark[4]  = "wentimiaoshu";
            oBookMark[5]  = "yinxiangfenxi";
            oBookMark[6]  = "chulijieguo";
            oBookMark[7]  = "baogaoren";
            oBookMark[8]  = "baogaoriqi";
            oBookMark[9]  = "kaifafang";
            oBookMark[10] = "ceshifang";
            //赋值任意数据到书签的位置
            oDoc.Bookmarks.get_Item(ref oBookMark[0]).Range.Text = name;
            oDoc.Bookmarks.get_Item(ref oBookMark[1]).Range.Text = banbenhao.ToString();
            oDoc.Bookmarks.get_Item(ref oBookMark[2]).Range.Text = dengji.ToString();
            oDoc.Bookmarks.get_Item(ref oBookMark[3]).Range.Text = name;

            string temp = "";

            for (int i = 0; i < cuowuleixingshumu; i++)
            {
                temp += "错误名称:";
                temp += data[i].name + "   ";
                temp += "错误数量:";
                temp += data[i].num.ToString();
                temp += "\n";
            }
            string a = "我是第一行\r\n" + "我是第二行";

            oDoc.Bookmarks.get_Item(ref oBookMark[4]).Range.Text = temp;
            if (cuowuleixingshumu == 0)
            {
                oDoc.Bookmarks.get_Item(ref oBookMark[5]).Range.Text = "无错误,影响良好";
            }
            else
            {
                oDoc.Bookmarks.get_Item(ref oBookMark[5]).Range.Text = "有错误,请及时修改";
            }
            oDoc.Bookmarks.get_Item(ref oBookMark[6]).Range.Text  = "";
            oDoc.Bookmarks.get_Item(ref oBookMark[7]).Range.Text  = "admin";
            oDoc.Bookmarks.get_Item(ref oBookMark[8]).Range.Text  = DateTime.Now.ToString();
            oDoc.Bookmarks.get_Item(ref oBookMark[9]).Range.Text  = "admin";
            oDoc.Bookmarks.get_Item(ref oBookMark[10]).Range.Text = "admin";

            //弹出保存文件对话框,保存生成的Word


            {
                // object filename = "J://学习//大三下//软件体系结构和设计模式//code//新导入.dot";
                object filename = NewFileAddress;
                oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing);
                oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                //关闭word
                oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
            }
            return(1);
        }
Ejemplo n.º 10
0
        private void save()
        {
            this.Enabled = false;

            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\522\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;//word模板路径

            OrignFile = "\\baseDB\\商标书式\\3 续展变更转让许可质押注销\\2变更\\2撤回变更商标申请人注册人名义地址变更集体商标证明商标管理规则集体成员名单申请书.dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\522\\" + a0.Text + "\\" + a0.Text + ".docx";

            object[] MyBM = new object[34]; //创建一个书签数组

            for (int i = 0; i < 9; i++)     //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }

            MyBM[9]  = "a10_1";
            MyBM[10] = "a10_2";
            MyBM[11] = "a11";
            MyBM[12] = "a12_1";
            MyBM[13] = "a12_2";
            for (int i = 14; i < 23; i++)//给书签数组赋值
            {
                MyBM[i] = "a" + (i - 1).ToString();
            }


            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text = a9.Text;

            if (a10.Text == "是")
            {
                doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text = "✔";
            }
            if (a10.Text == "否")
            {
                doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = "✔";
            }



            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a11.Text;

            if (a12_1.CheckState == CheckState.Checked)
            {
                doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = "✔";
            }
            if (a12_2.CheckState == CheckState.Checked)
            {
                doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = "✔";
            }


            doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = a14.Text;


            doc.Bookmarks.get_Item(ref MyBM[16]).Range.Text = a15.Text;
            doc.Bookmarks.get_Item(ref MyBM[17]).Range.Text = a16.Text;
            doc.Bookmarks.get_Item(ref MyBM[18]).Range.Text = a17.Text;
            doc.Bookmarks.get_Item(ref MyBM[19]).Range.Text = a18.Text;

            doc.Bookmarks.get_Item(ref MyBM[20]).Range.Text = a19.Text;
            doc.Bookmarks.get_Item(ref MyBM[21]).Range.Text = a20.Text;
            doc.Bookmarks.get_Item(ref MyBM[22]).Range.Text = a21.Text;

            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 11
0
        private void save()
        {
            this.Enabled = false;
            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\101\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;

            OrignFile = "\\baseDB\\商标书式\\1 注册申请\\01 商标注册申请书.dot";

            //开始写入数据

            int a13_1_a = 0, a13_2_a = 0, a13_3_a = 0, a13_4_a = 0, a13_5_a = 0, a13_6_a = 0;

            if (a13_1.CheckState == CheckState.Checked)
            {
                a13_1_a = 1;
            }
            if (a13_2.CheckState == CheckState.Checked)
            {
                a13_2_a = 1;
            }
            if (a13_3.CheckState == CheckState.Checked)
            {
                a13_3_a = 1;
            }
            if (a13_4.CheckState == CheckState.Checked)
            {
                a13_4_a = 1;
            }
            if (a13_5.CheckState == CheckState.Checked)
            {
                a13_5_a = 1;
            }
            if (a13_6.CheckState == CheckState.Checked)
            {
                a13_6_a = 1;
            }



            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\101\\" + a0.Text + "\\" + a0.Text + ".docx"; //命名更改

            object[] MyBM = new object[30];                                                                    //创建一个书签数组

            for (int i = 0; i < 12; i++)                                                                       //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }
            MyBM[12] = "a13_1";
            MyBM[13] = "a13_2";
            MyBM[14] = "a13_3";
            MyBM[15] = "a13_4";
            MyBM[16] = "a13_5";
            MyBM[17] = "a13_6";
            MyBM[18] = "a14_1";
            MyBM[19] = "a14_2";
            MyBM[20] = "a14_3";

            MyBM[21] = "a15";
            MyBM[22] = "a16";
            MyBM[23] = "a17";
            MyBM[24] = "a18";
            MyBM[25] = "a19";
            MyBM[26] = "a20";
            MyBM[27] = "a21";
            MyBM[28] = "a22";
            MyBM[29] = "a25";



            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text  = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text  = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text  = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text  = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text  = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text  = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text  = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text  = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text  = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text  = a10.Text;
            doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = a11.Text;
            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a12.Text;
            string xx;

            if (a13_1_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = xx;
            if (a13_2_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = xx;
            if (a13_3_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = xx;
            if (a13_4_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[15]).Range.Text = xx;
            if (a13_5_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[16]).Range.Text = xx;
            if (a13_6_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[17]).Range.Text = xx;

            switch (a14.Text)
            {
            case "基于第一次申请的优先权":
                doc.Bookmarks.get_Item(ref MyBM[18]).Range.Text = "✔";
                break;

            case "基于展会的优先权":
                doc.Bookmarks.get_Item(ref MyBM[19]).Range.Text = "✔";
                break;

            case "优先权证明文件后补":
                doc.Bookmarks.get_Item(ref MyBM[20]).Range.Text = "✔";
                break;

            default:
                break;
            }


            doc.Bookmarks.get_Item(ref MyBM[21]).Range.Text = a15.Text;
            doc.Bookmarks.get_Item(ref MyBM[22]).Range.Text = a16.Text;
            doc.Bookmarks.get_Item(ref MyBM[23]).Range.Text = a17.Text;
            doc.Bookmarks.get_Item(ref MyBM[24]).Range.Text = a18.Text;
            doc.Bookmarks.get_Item(ref MyBM[25]).Range.Text = a19.Text;
            doc.Bookmarks.get_Item(ref MyBM[26]).Range.Text = a20.Text;
            doc.Bookmarks.get_Item(ref MyBM[27]).Range.Text = a21.Text;
            doc.Bookmarks.get_Item(ref MyBM[28]).Range.Text = a22.Text;
            doc.Bookmarks.get_Item(ref MyBM[29]).Range.Text = a25.Text;



            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 12
0
        public void FillDataToWord(Dictionary <string, object> dic)
        {
            try
            {
                object oMissing = System.Reflection.Missing.Value;
                //创建一个Word应用程序实例
                Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
                //设置为不可见
                oWord.Visible = false;
                //模板文件地址
                object oTemplate = BasePath + "\\module\\recordModule.docx";
                //以模板为基础生成文档
                Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
                //声明书签数组
                object[] oBookMark = new object[dic.Count];
                //赋值书签名
                //List<string> keyString = new List<string>(dic.Keys);
                //for (int i = 0; i < keyString.Count; i++)
                //{
                //    oBookMark[i] = keyString[i];
                //}
                oBookMark[0] = "sn";
                oBookMark[1] = "productionType";
                oBookMark[2] = "onlineDate";
                oBookMark[3] = "offlineDate";
                oBookMark[4] = "materialData";
                oBookMark[5] = "boltData";
                oBookMark[6] = "leakageData";
                System.Data.DataTable materialtable = (System.Data.DataTable)dic["material"];
                System.Data.DataTable bolttable     = (System.Data.DataTable)dic["bolt"];
                System.Data.DataTable leakagetable  = (System.Data.DataTable)dic["leakage"];
                //赋值任意数据到书签的位置
                oDoc.Bookmarks.get_Item(ref oBookMark[0]).Range.Text = dic["sn"].ToString();
                oDoc.Bookmarks.get_Item(ref oBookMark[1]).Range.Text = dic["productionType"].ToString();
                if (dic["onlineDate"] != null)
                {
                    oDoc.Bookmarks.get_Item(ref oBookMark[2]).Range.Text = dic["onlineDate"].ToString();
                }
                if (dic["offlineDate"] != null)
                {
                    oDoc.Bookmarks.get_Item(ref oBookMark[3]).Range.Text = dic["offlineDate"].ToString();
                }
                if (materialtable.Rows.Count > 0)
                {
                    Microsoft.Office.Interop.Word.Table newTable = oDoc.Tables.Add(oDoc.Bookmarks.get_Item(ref oBookMark[4]).Range, materialtable.Rows.Count + 1, materialtable.Columns.Count);
                    newTable.set_Style("网格型");
                    //设置首行标题
                    newTable.Rows[1].Cells[1].Range.Text = "日期";
                    newTable.Rows[1].Cells[2].Range.Text = "名称";
                    newTable.Rows[1].Cells[3].Range.Text = "批次号";
                    newTable.Rows[1].Cells[4].Range.Text = "员工号";
                    newTable.Rows[1].Cells[5].Range.Text = "工位";
                    for (int i = 1; i <= materialtable.Rows.Count; i++)
                    {
                        for (int j = 0; j < materialtable.Columns.Count; j++)
                        {
                            newTable.Rows[i + 1].Cells[j + 1].Range.Text = materialtable.Rows[i - 1][j].ToString();
                        }
                    }
                }
                if (bolttable.Rows.Count > 0)
                {
                    Microsoft.Office.Interop.Word.Table boltDataTable = oDoc.Tables.Add(oDoc.Bookmarks.get_Item(ref oBookMark[5]).Range, bolttable.Rows.Count + 1, bolttable.Columns.Count);
                    boltDataTable.set_Style("网格型");
                    //设置首行标题
                    boltDataTable.Rows[1].Cells[1].Range.Text = "日期";
                    boltDataTable.Rows[1].Cells[2].Range.Text = "名称";
                    boltDataTable.Rows[1].Cells[3].Range.Text = "角度值°";
                    boltDataTable.Rows[1].Cells[4].Range.Text = "扭矩值N/M";
                    boltDataTable.Rows[1].Cells[5].Range.Text = "结果";
                    boltDataTable.Rows[1].Cells[6].Range.Text = "员工号";
                    boltDataTable.Rows[1].Cells[7].Range.Text = "工位";
                    for (int i = 1; i <= bolttable.Rows.Count; i++)
                    {
                        for (int j = 0; j < bolttable.Columns.Count; j++)
                        {
                            boltDataTable.Rows[i + 1].Cells[j + 1].Range.Text = bolttable.Rows[i - 1][j].ToString();
                            boltDataTable.Rows[i].Cells[1].Width = 80;
                            boltDataTable.Rows[i].Cells[2].Width = 95;
                            boltDataTable.Rows[i].Cells[3].Width = 50;
                            boltDataTable.Rows[i].Cells[4].Width = 50;
                            boltDataTable.Rows[i].Cells[5].Width = 30;
                            boltDataTable.Rows[i].Cells[6].Width = 90;
                            boltDataTable.Rows[i].Cells[7].Width = 30;
                        }
                    }
                    //设置末行宽度
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[1].Width = 80;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[2].Width = 95;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[3].Width = 50;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[4].Width = 50;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[5].Width = 30;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[6].Width = 90;
                    boltDataTable.Rows[boltDataTable.Rows.Count].Cells[7].Width = 30;
                }
                if (leakagetable.Rows.Count > 0)
                {
                    Microsoft.Office.Interop.Word.Table leakageDataTable = oDoc.Tables.Add(oDoc.Bookmarks.get_Item(ref oBookMark[6]).Range, leakagetable.Rows.Count + 1, leakagetable.Columns.Count);
                    leakageDataTable.set_Style("网格型");
                    //设置首行标题
                    leakageDataTable.Rows[1].Cells[1].Range.Text = "日期";
                    leakageDataTable.Rows[1].Cells[2].Range.Text = "气压值";
                    leakageDataTable.Rows[1].Cells[3].Range.Text = "泄漏值";
                    leakageDataTable.Rows[1].Cells[4].Range.Text = "结果";
                    leakageDataTable.Rows[1].Cells[5].Range.Text = "员工号";
                    leakageDataTable.Rows[1].Cells[6].Range.Text = "工位";
                    for (int i = 1; i <= leakagetable.Rows.Count; i++)
                    {
                        for (int j = 0; j < leakagetable.Columns.Count; j++)
                        {
                            leakageDataTable.Rows[i + 1].Cells[j + 1].Range.Text = leakagetable.Rows[i - 1][j].ToString();
                            leakageDataTable.Rows[i].Cells[1].Width = 80;
                            leakageDataTable.Rows[i].Cells[2].Width = 40;
                            leakageDataTable.Rows[i].Cells[3].Width = 40;
                            leakageDataTable.Rows[i].Cells[4].Width = 30;
                            leakageDataTable.Rows[i].Cells[5].Width = 100;
                            leakageDataTable.Rows[i].Cells[6].Width = 30;
                            //newTable.Rows[i].Cells[7].Width = 30;
                        }
                    }
                    //设置末行宽度
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[1].Width = 80;
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[2].Width = 40;
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[3].Width = 40;
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[4].Width = 30;
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[5].Width = 100;
                    leakageDataTable.Rows[leakageDataTable.Rows.Count].Cells[6].Width = 30;
                }

                //弹出保存文件对话框,保存生成的Word
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "Word Document(*.doc)|*.doc";
                // sfd.DefaultExt = "Word Document(*.doc)|*.doc";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    object filename = sfd.FileName;
                    //object filename = BasePath + "\\module\\recordModule2017.docx";
                    oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing);
                    MessageBox.Show("保存成功!");
                    oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                    //关闭word
                    oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
                    Thread.Sleep(1000);
                    //  DSO_Record.Open(filename.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        static private void start_Operation()
        {
            while (true)
            {
                if (file_Paths.Count == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
                else
                {
                    try
                    {
                        //System.Threading.Interlocked.Increment(ref word_Application_Count);

                        while (file_Paths.Count > 0)
                        {
                            string temp_String = "";
                            if (file_Paths.TryDequeue(out temp_String))
                            {
                                string[] temp_Collection       = temp_String.Split(new string[] { "|^|" }, StringSplitOptions.None);
                                string   file_Path             = temp_Collection[0];
                                string   web_Page_Base_Address = temp_Collection[1];
                                string   folder_Path           = file_Path.Substring(0, file_Path.LastIndexOf("\\"));
                                string   file_Name             = file_Path.Substring(file_Path.LastIndexOf("\\") + 1);
                                if (!System.IO.File.Exists(file_Path))
                                {
                                    return;// continue;
                                }
                                string file_Name_Htm = folder_Path + "\\HTML\\" + System.IO.Path.ChangeExtension(file_Name, "htm");
                                if (System.IO.File.Exists(file_Name_Htm))
                                {
                                    return;// continue;
                                }
                                Microsoft.Office.Interop.Word._Document doc = app.Documents.Open(file_Path, Visible: false);
                                //Console.WriteLine(file_Name_Htm);
                                doc.SaveAs(FileName: file_Name_Htm, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML);
                                System.Threading.ThreadPool.QueueUserWorkItem((state) => {
                                    HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

                                    // There are various options, set as needed
                                    htmlDoc.OptionFixNestedTags = true;

                                    // filePath is a path to a file containing the html
                                    //string filePath = @"C:\Documents and Settings\prabhakaran\Desktop\rv_3b72167e18a54fe28a330c5fbecc222f.htm";
                                    string filePath = file_Name_Htm;
                                    while (true)
                                    {
                                        try
                                        {
                                            htmlDoc.Load(filePath);
                                            break;
                                        }
                                        catch (Exception excp)
                                        {
                                        }
                                    }

                                    // Use:  htmlDoc.LoadXML(xmlString);  to load from a string

                                    // ParseErrors is an ArrayList containing any errors from the Load statement
                                    if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
                                    {
                                        // Handle any parse errors as required
                                    }
                                    else
                                    {
                                        if (htmlDoc.DocumentNode != null)
                                        {
                                            HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");

                                            if (bodyNode != null)
                                            {
                                                bodyNode.SetAttributeValue("onload", "var temp_Element_Pdf = document.getElementById('PDF Link');temp_Element_Pdf.style.width=screen.width/2;temp_Element_Pdf.style.height='50';var temp_Element_Doc = document.getElementById('DOC Link');temp_Element_Doc.style.width=screen.width/2;temp_Element_Doc.style.height='50';temp_Element_Doc.style.position='absolute';");

                                                HtmlNode pdf_Link = htmlDoc.CreateElement("button"); //new HtmlNode(HtmlNodeType.Element, htmlDoc, 0);
                                                pdf_Link.SetAttributeValue("value", "PDF");
                                                pdf_Link.SetAttributeValue("id", "PDF Link");
                                                string pdf_Path = web_Page_Base_Address + "Local_Database/PDF/" + System.IO.Path.ChangeExtension(file_Name, "pdf");
                                                pdf_Link.SetAttributeValue("onclick", "window.open('" + pdf_Path + "','_blank','location=no,menubar=no,status=no,toolbar=no');");
                                                pdf_Link.InnerHtml = "PDF";
                                                pdf_Link.SetAttributeValue("style", "background-color:#262626;color:#747474;border-style:groove;border-color:#121212;-moz-appearance:none;");
                                                pdf_Link.SetAttributeValue("onmouseover", "this.style.backgroundColor='#262626';this.style.color='#adbdde';this.style.fontWeight='bold';this.style.fontSize='normal';this.style.borderColor='#afafaf';");  //#afafaf
                                                pdf_Link.SetAttributeValue("onmouseout", "this.style.backgroundColor='#262626';this.style.color='#747474';this.style.fontWeight='normal';this.style.fontSize='normal';this.style.borderColor='#121212';");
                                                bodyNode.ChildNodes.Add(pdf_Link);

                                                HtmlNode doc_Link = htmlDoc.CreateElement("button"); //new HtmlNode(HtmlNodeType.Element, htmlDoc, 0);
                                                doc_Link.SetAttributeValue("value", "DOC");
                                                doc_Link.SetAttributeValue("id", "DOC Link");
                                                string doc_Path = web_Page_Base_Address + "Local_Database/DOC/" + System.IO.Path.ChangeExtension(file_Name, "doc");
                                                doc_Link.SetAttributeValue("onclick", "window.open('" + doc_Path + "','_blank','location=no,menubar=no,status=no,toolbar=no');");
                                                doc_Link.InnerHtml = "DOC";
                                                doc_Link.SetAttributeValue("style", "background-color:#262626;color:#747474;border-style:groove;border-color:#121212;-moz-appearance:none;");
                                                doc_Link.SetAttributeValue("onmouseover", "this.style.backgroundColor='#262626';this.style.color='#adbdde';this.style.fontWeight='bold';this.style.fontSize='normal';this.style.borderColor='#afafaf';");  //#afafaf
                                                doc_Link.SetAttributeValue("onmouseout", "this.style.backgroundColor='#262626';this.style.color='#747474';this.style.fontWeight='normal';this.style.fontSize='normal';this.style.borderColor='#121212';");
                                                bodyNode.ChildNodes.Add(doc_Link);

                                                //htmlDoc.Save(@"C:\Documents and Settings\prabhakaran\Desktop\new.html");
                                                htmlDoc.Save(file_Name_Htm);

                                                // Do something with bodyNode
                                            }
                                        }
                                    }// ***
                                });


                                string file_Name_Pdf = folder_Path + "\\PDF\\" + System.IO.Path.ChangeExtension(file_Name, "pdf");
                                //Console.WriteLine(file_Name_Pdf);
                                doc.SaveAs(FileName: file_Name_Pdf, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF);
                                //Console.WriteLine(folder_Path + "\\DOC\\" + file_Name);
                                ((Microsoft.Office.Interop.Word._Document)doc).Close(SaveChanges: Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges);
                                while (true)
                                {
                                    try
                                    {
                                        System.IO.File.Move(file_Path, folder_Path + "\\DOC\\" + file_Name);
                                        break;
                                    }
                                    catch (Exception excp)
                                    {
                                    }
                                }
                            }
                        }
                        //System.Threading.Interlocked.Decrement(ref word_Application_Count);
                    }
                    catch (Exception excp)
                    {
                        Console.WriteLine(excp.Message);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void save()
        {
            this.Enabled = false;

            // thw new NotImplementedException();
            int a8_1_a = 0, a8_2_a = 0, a8_3_a = 0;

            if (a8_1.CheckState == CheckState.Checked)
            {
                a8_1_a = 1;
            }
            if (a8_2.CheckState == CheckState.Checked)
            {
                a8_2_a = 1;
            }
            if (a8_3.CheckState == CheckState.Checked)
            {
                a8_3_a = 1;
            }


            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\301\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;

            OrignFile = "\\baseDB\\商标书式\\5 补证撤三出具证明\\01 补发变更转让续展证明申请书.dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + ".\\" + main.companyName + "\\wjgl\\301\\" + a0.Text + "\\" + a0.Text + ".docx"; //命名更改

            object[] MyBM = new object[15];                                                                     //创建一个书签数组

            for (int i = 0; i < 7; i++)                                                                         //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }
            MyBM[7]  = "a8_1";
            MyBM[8]  = "a8_2";
            MyBM[9]  = "a8_3";
            MyBM[10] = "a9";
            MyBM[11] = "a10";
            MyBM[12] = "a11";
            MyBM[13] = "a12";
            MyBM[14] = "a13";



            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text = a7.Text;



            string xx;

            if (a8_1_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text = xx;
            if (a8_2_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text = xx;
            if (a8_3_a == 1)
            {
                xx = "✔";
            }
            else
            {
                xx = " ";
            }
            doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text = xx;



            doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a10.Text;
            doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = a11.Text;
            doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = a12.Text;
            doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = a13.Text;



            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 15
0
        private void save()
        {
            this.Enabled = true;
            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\6\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;//word模板路径

            OrignFile = "\\baseDB\\商标书式\\6 商标代理委托书\\商标代理委托书(示范文本).dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\6\\" + a0.Text + "\\" + a0.Text + ".docx";

            object[] MyBM = new object[57]; //创建一个书签数组

            for (int i = 0; i < 4; i++)     //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }
            for (int i = 4; i < 42; i++)
            {
                MyBM[i] = "a5_" + (i - 3).ToString();
            }
            for (int i = 42; i < 55; i++)
            {
                MyBM[i] = "a" + (i - 36).ToString();
            }
            MyBM[46] = "a10_1";
            MyBM[55] = "a10_2";
            MyBM[56] = "a10_3";
            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text = a4.Text;

            if (a5.Text == "商标注册申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text = "✔";
            }
            else if (a5.Text == "商标异议申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text = "✔";
            }
            else if (a5.Text == "商标异议答辩")
            {
                doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text = "✔";
            }
            else if (a5.Text == "更正商标申请/注意事项申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text = "✔";
            }
            else if (a5.Text == "变更商标申请人/注册人名义/地址 变更集体商标/证明商标管理规则/集体成员名单申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text = "✔";
            }
            else if (a5.Text == "变更商标代理人/文件接收人申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text = "✔";
            }
            else if (a5.Text == "删减商品/服务项目申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = "✔";
            }
            else if (a5.Text == "商标续展注册申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = "✔";
            }
            else if (a5.Text == "商标注册申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = "✔";
            }
            else if (a5.Text == "转让/移转申请/注册商标申请书")
            {
                doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = "✔";
            }
            else if (a5.Text == "商标使用许可备案")
            {
                doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = "✔";
            }
            else if (a5.Text == "变更许可人/被许可人名称备案")
            {
                doc.Bookmarks.get_Item(ref MyBM[15]).Range.Text = "✔";
            }
            else if (a5.Text == "商标专用权质权登记申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[16]).Range.Text = "✔";
            }
            else if (a5.Text == "商标专用权质权登记事项变更申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[17]).Range.Text = "✔";
            }
            else if (a5.Text == "商标专用权质权登记期限延期申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[18]).Range.Text = "✔";
            }
            else if (a5.Text == "商标专用权质权登记证补发申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[19]).Range.Text = "✔";
            }
            else if (a5.Text == "商标专用权质权登记注销申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[20]).Range.Text = "✔";
            }
            else if (a5.Text == "商标注销申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[21]).Range.Text = "✔";
            }
            else if (a5.Text == "撤销连续三年不使用注册商标申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[22]).Range.Text = "✔";
            }
            else if (a5.Text == "撤销成为商品/服务通用名称注册商标申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[23]).Range.Text = "✔";
            }
            else if (a5.Text == "撤销连续三年不使用注册商标提供证据")
            {
                doc.Bookmarks.get_Item(ref MyBM[24]).Range.Text = "✔";
            }
            else if (a5.Text == "撤销成为商品/服务通用名称注册商标答辩")
            {
                doc.Bookmarks.get_Item(ref MyBM[25]).Range.Text = "✔";
            }
            else if (a5.Text == "补发变更/转让/续展证明申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[26]).Range.Text = "✔";
            }
            else if (a5.Text == "补发商标注册证申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[27]).Range.Text = "✔";
            }
            else if (a5.Text == "出具商标注册证明申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[28]).Range.Text = "✔";
            }
            else if (a5.Text == "出具优先权证明文件申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[29]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回商标注册申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[30]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回商标异议申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[31]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回变更商标申请人/注册人名义/地址 变更集体商标/证明商标管理规则/集体成员名单申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[32]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回变更商标代理人/文件接收人申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[33]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回删减商品/服务项目申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[34]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回商标续展注册申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[35]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回转让/移转申请/注册商标申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[36]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回商标使用许可备案")
            {
                doc.Bookmarks.get_Item(ref MyBM[37]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回商标注销申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[38]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回撤销连续三年不使用注册商标申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[39]).Range.Text = "✔";
            }
            else if (a5.Text == "撤回撤销成为商品/服务通用名称注册商标申请")
            {
                doc.Bookmarks.get_Item(ref MyBM[40]).Range.Text = "✔";
            }
            else
            {
                doc.Bookmarks.get_Item(ref MyBM[41]).Range.Text = a5.Text;
            }

            doc.Bookmarks.get_Item(ref MyBM[42]).Range.Text = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[43]).Range.Text = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[44]).Range.Text = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[45]).Range.Text = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[46]).Range.Text = a10_1.Text;
            doc.Bookmarks.get_Item(ref MyBM[55]).Range.Text = a10_2.Text;
            doc.Bookmarks.get_Item(ref MyBM[56]).Range.Text = a10_3.Text;

            /* doc.Bookmarks.get_Item(ref MyBM[47]).Range.Text = a11.Text;
             * doc.Bookmarks.get_Item(ref MyBM[48]).Range.Text = a12.Text;
             * doc.Bookmarks.get_Item(ref MyBM[49]).Range.Text = a13.Text;
             * doc.Bookmarks.get_Item(ref MyBM[50]).Range.Text = a14.Text;
             * doc.Bookmarks.get_Item(ref MyBM[51]).Range.Text = a15.Text;
             * doc.Bookmarks.get_Item(ref MyBM[52]).Range.Text = a16.Text;
             * doc.Bookmarks.get_Item(ref MyBM[53]).Range.Text = a17.Text;
             * doc.Bookmarks.get_Item(ref MyBM[54]).Range.Text = a18.Text;*/

            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
Ejemplo n.º 16
0
        public static void attestation(string raison, string spécialité, string image, string wilaya, string Rc, string matricule_fiscal, string date, string gérant, string employé, string date_naissance, string date_embauche, string poste, string chemin, string chemin1)
        {
            Microsoft.Office.Interop.Word.Application _ApplicationWord = new Microsoft.Office.Interop.Word.Application();
            _ApplicationWord.Visible = false;
            string path      = chemin1 + "\\Modeles\\REF-ATTESTATION DE TRAVAIL.docx";
            object oFileName = (object)@path;
            object Faux      = (object)false;
            object Vrai      = (object)true;
            object M         = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word._Document _MonDocument = _ApplicationWord.Documents.Add(ref oFileName, ref Faux, ref M, ref Vrai);

            object Nom   = (object)"date";
            object Nom1  = (object)"date1";
            object Nom2  = (object)"dateEmbauche";
            object Nom3  = (object)"dateNaissance";
            object Nom4  = (object)"employé";
            object Nom5  = (object)"gérant";
            object Nom6  = (object)"gérant1";
            object Nom7  = (object)"RcMatriculeFiscal";
            object Nom8  = (object)"poste";
            object Nom9  = (object)"raison";
            object Nom10 = (object)"raison1";
            object Nom11 = (object)"raison2";
            object Nom13 = (object)"spécialité";
            object Nom14 = (object)"wilaya";
            object Nom15 = (object)"wilaya1";
            object Nom16 = (object)"logo";



            Microsoft.Office.Interop.Word.Bookmark    _MonSignet;
            Microsoft.Office.Interop.Word.Range       _MonRange;
            Microsoft.Office.Interop.Word.InlineShape _MonImage;

            //récupére la liste de signets
            Microsoft.Office.Interop.Word.Bookmarks _MesSignets = _MonDocument.Bookmarks;

            //si le signet cherché existe
            if (_MesSignets.Exists("date"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date);
            }
            if (_MesSignets.Exists("date1"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom1);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date);
            }
            if (_MesSignets.Exists("dateEmbauche"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom2);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_embauche);
            }
            if (_MesSignets.Exists("dateNaissance"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom3);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_naissance);
            }
            if (_MesSignets.Exists("employé"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom4);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(employé);
            }
            if (_MesSignets.Exists("gérant"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom5);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant);
            }
            if (_MesSignets.Exists("gérant1"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom6);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant);
            }
            if (_MesSignets.Exists("RcMatriculeFiscal"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom7);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(Rc + "/" + matricule_fiscal);
            }
            if (_MesSignets.Exists("poste"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom8);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(poste);
            }
            if (_MesSignets.Exists("raison"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom9);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison1"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom10);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison2"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom11);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("spécialité"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom13);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(spécialité);
            }
            if (_MesSignets.Exists("wilaya"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom14);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya);
            }
            if (_MesSignets.Exists("wilaya1"))
            {
                //on positionne le range sur le signet et la fonction retourne true
                _MonSignet = _MesSignets.get_Item(ref Nom15);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya);
            }
            if (_MesSignets.Exists("logo"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom16);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonImage = _MonRange.InlineShapes.AddPicture(image + "\\logo.png", ref Faux, ref Vrai, ref M); //le chemin d'accès au logo image+ "\\Logo\\Logo.png"
            }


            oFileName = @chemin;
            _MonDocument.SaveAs(ref oFileName, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M);

            _MonDocument.Close(ref M, ref M, ref M);
            _ApplicationWord.Application.Quit(ref M, ref M, ref M);
        }
Ejemplo n.º 17
0
        public static void contratTravail(string raison, string spécialité, string wilaya, string Rc, string matricule_fiscal, string matricule, string nom, string prenom, string date_naissance, string wilaya_naissance, string adresse, string date_embauche, string poste, string salaire, string gérant, string chemin, string chemin1)
        {
            Microsoft.Office.Interop.Word.Application _ApplicationWord = new Microsoft.Office.Interop.Word.Application();
            _ApplicationWord.Visible = false;
            string path      = chemin1 + "\\Modeles\\REF-CONTRAT DE TRAVAIL .docx";
            object oFileName = (object)@path;
            object Faux      = (object)false;
            object Vrai      = (object)true;
            object M         = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word._Document _MonDocument = _ApplicationWord.Documents.Add(ref oFileName, ref Faux, ref M, ref Vrai);

            object Nom   = (object)"adresse";
            object Nom1  = (object)"DateEmbauche";
            object Nom2  = (object)"DateEmbauche1";
            object Nom3  = (object)"DateNaissance";
            object Nom4  = (object)"gérant";
            object Nom5  = (object)"matricule";
            object Nom6  = (object)"NomPrénom";
            object Nom7  = (object)"poste";
            object Nom8  = (object)"raison";
            object Nom9  = (object)"raison1";
            object Nom10 = (object)"raison2";
            object Nom11 = (object)"raison3";
            object Nom12 = (object)"raison4";
            object Nom13 = (object)"raison5";
            object Nom14 = (object)"raison6";
            object Nom15 = (object)"raison7";
            object Nom16 = (object)"RcMatriculeFiscal";
            object Nom17 = (object)"salaire";
            object Nom18 = (object)"salaire1";
            object Nom19 = (object)"spécialité";
            object Nom20 = (object)"wilaya";
            object Nom21 = (object)"WilayaNaissance";
            object Nom22 = (object)"logo";

            Microsoft.Office.Interop.Word.Bookmark    _MonSignet;
            Microsoft.Office.Interop.Word.Range       _MonRange;
            Microsoft.Office.Interop.Word.InlineShape _MonImage;



            //récupére la liste de signets
            Microsoft.Office.Interop.Word.Bookmarks _MesSignets = _MonDocument.Bookmarks;


            if (_MesSignets.Exists("adresse"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(adresse);
            }
            if (_MesSignets.Exists("DateEmbauche"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom1);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_embauche);
            }
            if (_MesSignets.Exists("DateEmbauche1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom2);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_embauche);
            }
            if (_MesSignets.Exists("DateNaissance"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom3);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_naissance);
            }
            if (_MesSignets.Exists("gérant"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom4);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant);
            }
            if (_MesSignets.Exists("matricule"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom5);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(matricule);
            }
            if (_MesSignets.Exists("NomPrénom"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom6);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + nom + " " + prenom + " ");
            }
            if (_MesSignets.Exists("poste"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom7);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(poste);
            }
            if (_MesSignets.Exists("raison"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom8);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom9);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison2"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom10);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison3"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom11);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison4"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom12);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison5"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom13);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison6"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom14);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("raison7"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom15);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison);
            }
            if (_MesSignets.Exists("RcMatriculeFiscal"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom16);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(Rc + "/" + matricule_fiscal);
            }
            if (_MesSignets.Exists("salaire"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom17);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                double sal = (Convert.ToDouble(salaire)) * 12;
                _MonRange.InsertAfter(Convert.ToString(sal));
            }
            if (_MesSignets.Exists("salaire1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom18);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(salaire);
            }
            if (_MesSignets.Exists("spécialité"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom19);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(spécialité);
            }
            if (_MesSignets.Exists("wilaya"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom20);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya);
            }
            if (_MesSignets.Exists("WilayaNaissance"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom21);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya_naissance);
            }
            if (_MesSignets.Exists("logo"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom22);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonImage = _MonRange.InlineShapes.AddPicture($@"{System.IO.Directory.GetCurrentDirectory()}\logo.png", ref Faux, ref Vrai, ref M);
            }



            oFileName = @chemin;
            try
            {
                _MonDocument.SaveAs(ref oFileName, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M);
            }
            catch (Exception e) { }
            _MonDocument.Close(ref M, ref M, ref M);
            _ApplicationWord.Application.Quit(ref M, ref M, ref M);
        }
Ejemplo n.º 18
0
        public static void certificatTravail(string raison, string spécialité, string wilaya, string Rc, string matricule_fiscal, string date, string gérant, string employé, string date_embauche, string date_emission, string poste, string chemin, string chemin1)
        {
            Microsoft.Office.Interop.Word.Application _ApplicationWord = new Microsoft.Office.Interop.Word.Application();
            _ApplicationWord.Visible = false;

            // chemin vers le modéle word qu'on doit remplir ...
            string path      = chemin1 + "\\Modeles\\REF-CERTIFICAT DE TRAVAIL.docx";
            object oFileName = (object)@path;
            object Faux      = (object)false;
            object Vrai      = (object)true;
            object M         = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word._Document _MonDocument = _ApplicationWord.Documents.Add(ref oFileName, ref Faux, ref M, ref Vrai);

            object Nom   = (object)"Date";
            object Nom1  = (object)"date1";
            object Nom2  = (object)"DateEmbauche";
            object Nom3  = (object)"DateEmission";
            object Nom4  = (object)"employé";
            object Nom5  = (object)"employé1";
            object Nom6  = (object)"gérant";
            object Nom7  = (object)"logo";
            object Nom8  = (object)"poste";
            object Nom9  = (object)"raison";
            object Nom10 = (object)"raison1";
            object Nom11 = (object)"raison2";
            object Nom12 = (object)"RcMatriculeFiscal";
            object Nom13 = (object)"spécialité";
            object Nom14 = (object)"wilaya";

            Microsoft.Office.Interop.Word.Bookmark    _MonSignet;
            Microsoft.Office.Interop.Word.Range       _MonRange;
            Microsoft.Office.Interop.Word.InlineShape _MonImage;



            //récupére la liste de signets
            Microsoft.Office.Interop.Word.Bookmarks _MesSignets = _MonDocument.Bookmarks;

            if (_MesSignets.Exists("Date"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date + " ");
            }
            if (_MesSignets.Exists("date1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom1);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + date + " ");
            }
            if (_MesSignets.Exists("DateEmbauche"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom2);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_embauche + " ");
            }
            if (_MesSignets.Exists("DateEmission"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom3);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(date_emission + " ");
            }
            if (_MesSignets.Exists("employé"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom4);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(employé + " ");
            }
            if (_MesSignets.Exists("employé1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom5);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(employé + " ");
            }
            if (_MesSignets.Exists("gérant"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom6);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(gérant + " ");
            }
            if (_MesSignets.Exists("logo"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom7);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonImage = _MonRange.InlineShapes.AddPicture(@chemin1 + "\\logo.png", ref Faux, ref Vrai, ref M);
            }
            if (_MesSignets.Exists("poste"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom8);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(" " + poste + " ");
            }
            if (_MesSignets.Exists("raison"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom9);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison + " ");
            }
            if (_MesSignets.Exists("raison1"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom10);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison + " ");
            }
            if (_MesSignets.Exists("raison2"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom11);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(raison + " ");
            }
            if (_MesSignets.Exists("RcMatriculeFiscal"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom12);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(Rc + "/" + matricule_fiscal + " ");
            }
            if (_MesSignets.Exists("spécialité"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom13);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(spécialité + " ");
            }
            if (_MesSignets.Exists("wilaya"))
            {
                _MonSignet = _MesSignets.get_Item(ref Nom14);
                _MonSignet.Select();
                _MonRange = _MonSignet.Range;
                _MonRange.Delete(ref M, 1);
                _MonRange.InsertAfter(wilaya + "- Algérie");
            }


            // le fichier généré et son chemin ....
            oFileName = @chemin;
            _MonDocument.SaveAs(ref oFileName, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M, ref M);

            _MonDocument.Close(ref M, ref M, ref M);
            _ApplicationWord.Application.Quit(ref M, ref M, ref M);
        }
Ejemplo n.º 19
0
        private void save()
        {
            this.Enabled = true;
            Directory.CreateDirectory(".\\" + main.companyName + "\\wjgl\\563\\" + a0.Text + "");

            string temp = System.IO.Directory.GetCurrentDirectory();// d当前运行路径

            //    MessageBox.Show(temp);
            string OrignFile;//word模板路径

            OrignFile = "\\baseDB\\商标书式\\3 续展变更转让许可质押注销\\6质押\\3商标专用权质权登记期限延期申请书.dot";

            //开始写入数据

            string parFilePath = temp + OrignFile;//文件路径
            object FilePath    = parFilePath;

            Microsoft.Office.Interop.Word._Application AppliApp = new Microsoft.Office.Interop.Word.Application();
            AppliApp.Visible = false;
            Microsoft.Office.Interop.Word._Document doc = AppliApp.Documents.Add(ref FilePath);
            object missing    = System.Reflection.Missing.Value;
            object isReadOnly = false;



            doc.Activate();

            //数据写入代码段


            object aa = temp + "\\" + main.companyName + "\\wjgl\\563\\" + a0.Text + "\\" + a0.Text + ".docx";

            object[] MyBM = new object[34]; //创建一个书签数组

            for (int i = 0; i < 34; i++)    //给书签数组赋值
            {
                MyBM[i] = "a" + (i + 1).ToString();
            }

            //给对应的书签位置写入数据
            doc.Bookmarks.get_Item(ref MyBM[0]).Range.Text  = a1.Text;
            doc.Bookmarks.get_Item(ref MyBM[1]).Range.Text  = a2.Text;
            doc.Bookmarks.get_Item(ref MyBM[2]).Range.Text  = a3.Text;
            doc.Bookmarks.get_Item(ref MyBM[3]).Range.Text  = a4.Text;
            doc.Bookmarks.get_Item(ref MyBM[4]).Range.Text  = a5.Text;
            doc.Bookmarks.get_Item(ref MyBM[5]).Range.Text  = a6.Text;
            doc.Bookmarks.get_Item(ref MyBM[6]).Range.Text  = a7.Text;
            doc.Bookmarks.get_Item(ref MyBM[7]).Range.Text  = a8.Text;
            doc.Bookmarks.get_Item(ref MyBM[8]).Range.Text  = a9.Text;
            doc.Bookmarks.get_Item(ref MyBM[9]).Range.Text  = a10.Text;
            doc.Bookmarks.get_Item(ref MyBM[10]).Range.Text = a11.Text;
            doc.Bookmarks.get_Item(ref MyBM[11]).Range.Text = a12.Text;
            doc.Bookmarks.get_Item(ref MyBM[12]).Range.Text = a13.Text;
            doc.Bookmarks.get_Item(ref MyBM[13]).Range.Text = a14.Text;
            doc.Bookmarks.get_Item(ref MyBM[14]).Range.Text = a15.Text;
            doc.Bookmarks.get_Item(ref MyBM[15]).Range.Text = a16.Text;
            doc.Bookmarks.get_Item(ref MyBM[16]).Range.Text = a17.Text;
            doc.Bookmarks.get_Item(ref MyBM[17]).Range.Text = a18.Text;
            doc.Bookmarks.get_Item(ref MyBM[18]).Range.Text = a19.Text;
            doc.Bookmarks.get_Item(ref MyBM[19]).Range.Text = a20.Text;
            doc.Bookmarks.get_Item(ref MyBM[20]).Range.Text = a21.Text;
            doc.Bookmarks.get_Item(ref MyBM[21]).Range.Text = a22.Text;
            doc.Bookmarks.get_Item(ref MyBM[22]).Range.Text = a23.Text;
            doc.Bookmarks.get_Item(ref MyBM[23]).Range.Text = a24.Text;
            doc.Bookmarks.get_Item(ref MyBM[24]).Range.Text = a25.Text;
            doc.Bookmarks.get_Item(ref MyBM[25]).Range.Text = a26.Text;
            doc.Bookmarks.get_Item(ref MyBM[26]).Range.Text = a27.Text;
            doc.Bookmarks.get_Item(ref MyBM[27]).Range.Text = a28.Text;
            doc.Bookmarks.get_Item(ref MyBM[28]).Range.Text = a29.Text;
            doc.Bookmarks.get_Item(ref MyBM[29]).Range.Text = a30.Text;
            doc.Bookmarks.get_Item(ref MyBM[30]).Range.Text = a31.Text;
            doc.Bookmarks.get_Item(ref MyBM[31]).Range.Text = a32.Text;
            doc.Bookmarks.get_Item(ref MyBM[32]).Range.Text = a33.Text;
            doc.Bookmarks.get_Item(ref MyBM[33]).Range.Text = a34.Text;

            doc.SaveAs(ref aa);
            doc.Close();
            this.Enabled = true;
        }
        private void button2_Click_1(object sender, EventArgs e)
        {
            object oTemplate = "";
            object oMissing  = System.Reflection.Missing.Value;

            //创建一个Word应用程序实例
            Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
            //设置为不可见
            oWord.Visible = false;
            //模板文件地址,这里假设在X盘根目录
            try
            {
                OpenFileDialog openFileDialogEmpImage = new OpenFileDialog();
                //          openFileDialogEmpImage.Filter = "*.jpg|*.jpg|*.png|*.png|*.bmp|*.bmp|*.tiff|*.tiff";//图片格式
                if (openFileDialogEmpImage.ShowDialog() == DialogResult.OK)
                {
                    //           isUpLoadPicture = true;//记录是否上传了相片,用于后面保存操作使用:是一个成员变
                    try
                    {
                        empUpLoadPictureRealPos = openFileDialogEmpImage.FileName;//实际的文件路径+文件名
                        String[] empImageData = empUpLoadPictureRealPos.Split('.');
                        //empImageData[1]:是上传的图片的后缀名
                        empUpLoadPictureFormat = empImageData[1];
                        oTemplate = openFileDialogEmpImage.FileName;
                    }
                    catch
                    {
                        MessageBox.Show("您选择的文件不能被读取或文件类型不对!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch
            {
            }
            //       object oTemplate = "C:\\Users\\IHCI\\Desktop\\档案领取交接单.dot";
            //以模板为基础生成文档
            Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
            //声明书签数组
            object[] oBookMark = new object[11];
            //赋值书签名
            oBookMark[0]  = "a1";
            oBookMark[1]  = "a2";
            oBookMark[2]  = "a3";
            oBookMark[3]  = "a4";
            oBookMark[4]  = "a5";
            oBookMark[5]  = "a6";
            oBookMark[6]  = "a7";
            oBookMark[7]  = "a8";
            oBookMark[8]  = "a9";
            oBookMark[9]  = "a10";
            oBookMark[10] = "a11";
            //赋值任意数据到书签的位置
            oDoc.Bookmarks.get_Item(ref oBookMark[0]).Range.Text  = textBoxXMDW.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[1]).Range.Text  = textBoxLQPCH.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[2]).Range.Text  = dateTimePickerlLQSJ.Value.ToString("yyyy-MM-dd");
            oDoc.Bookmarks.get_Item(ref oBookMark[3]).Range.Text  = textBoxDALX.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[4]).Range.Text  = textBoxGDFS.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[5]).Range.Text  = textBoxNX.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[6]).Range.Text  = textBox.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[7]).Range.Text  = textBoxJGDW.Text.Trim();
            oDoc.Bookmarks.get_Item(ref oBookMark[8]).Range.Text  = dateTimePickerRQ1.Value.ToString("yyyy-MM-dd");
            oDoc.Bookmarks.get_Item(ref oBookMark[9]).Range.Text  = dateTimePickerRQ2.Value.ToString("yyyy-MM-dd");
            oDoc.Bookmarks.get_Item(ref oBookMark[10]).Range.Text = textBoxDH.Text.Trim();

            //弹出保存文件对话框,保存生成的Word
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter     = "Word Document(*.doc)|*.doc";
            sfd.DefaultExt = "Word Document(*.doc)|*.doc";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                object filename = sfd.FileName;

                oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                            ref oMissing, ref oMissing);
                oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                //关闭word
                oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
            }
            ExportToExcel d = new ExportToExcel();

            d.OutputAsExcelFile(dataGridView1);
        }