当前位置: 首页>>代码示例>>C#>>正文


C# Document.SaveAs方法代码示例

本文整理汇总了C#中System.Windows.Forms.Document.SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C# Document.SaveAs方法的具体用法?C# Document.SaveAs怎么用?C# Document.SaveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Document的用法示例。


在下文中一共展示了Document.SaveAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRegToSysResource

        /// <summary>
        /// put new regulation document into system resource and extract toc 
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public Dictionary<string, List<TermContainer>> AddRegToSysResource(string filepath)
        {
            string fname = filepath.Substring(filepath.LastIndexOf("\\") + 1, filepath.LastIndexOf(".") - filepath.LastIndexOf("\\") - 1);
            putNewRegTocInINIFile(fname);

            ApplicationClass regWord = new ApplicationClass();
            Document regDoc = new Document();
            HandleDocument handleDocument = new HandleDocument();
  
            regDoc = handleDocument.openDocument(filepath, regWord);
            
            Table table = regDoc.Tables[1];
            int rows = table.Rows.Count;
            Dictionary<string, List<TermContainer>> dic = new Dictionary<string, List<TermContainer>>();
            
            string key = "";
            string section = "";
            for(int i = 1;i<= rows;i++)
            {                 
                string text = getTableCellText(table, i, 1);               
                if (isLevel1Cell(text))
                {
                    section = "";
                    key = text; 
                    dic.Add(text, new List<TermContainer>());             
                }
                else 
                {
                    if (isLevelSection(text))
                    {                  
                        section = text;
                    }
                    else
                    {
                        TermContainer term = getTableCellContainer(section,table, i);
                        dic[key].Add(term);
                    }
                }
            }

            string path = System.Environment.CurrentDirectory;
            string name = path + "\\resources\\"+regDoc.Name;
            object saveAsName = path + "\\resources\\" + regDoc.Name;
            
            object unknow = Type.Missing;

            if (!File.Exists(name))
            {
                regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
            }
            else
            {
                //shifou ti huan
                File.Delete(name);
                regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
            }
            quit(regWord, regDoc);
            return dic;
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:64,代码来源:TableOfContents.cs

示例2: cmdViewContracts_Click


//.........这里部分代码省略.........
            object missing = Type.Missing;

            try
            {
                doc = word.Documents.Open(ref sourcefile, 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);
                doc.Activate();
                if (!Utilities.Replace_String_In_Word_File(ref doc, "#TEN KHACH HANG#", benvay))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                    return;
                    //doc.SaveAs(ref destfile, 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);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Dia chi khach hang#", Diachi))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Dien thoai#", soDT))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Tong so tien#", sotien))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Laisuat#", laisuat))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Thoihan#", kyhan))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Donvi#", cbxDonvitinh.Text))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Ngayhopdong#", cbxDateContracts.Value.ToShortDateString()))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Ngaydaohan#", ngaydaohan.ToShortDateString()))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Phiuythacvon#", txtPhiUT.Text))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Account Numver#", BankAccount))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Bank Name#", BankName))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                if (!Utilities.Replace_String_In_Word_File(ref doc, "#Loinhuan#", strLoinhuan))
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }

                doc.SaveAs(ref destfile, 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);
                doc.Close(ref missing, ref missing, ref missing);
                word.Application.Quit(ref missing, ref missing, ref missing);
                Proc.StartInfo.FileName = @"WINWORD.EXE";
                Proc.StartInfo.Arguments = destfile.ToString();
                Proc.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                doc.Close(ref missing, ref missing, ref missing);
                word.Application.Quit(ref missing, ref missing, ref missing);
            }
        }
开发者ID:ViniciusConsultor,项目名称:quanlydongtien,代码行数:101,代码来源:NhapthongtinHD.cs


注:本文中的System.Windows.Forms.Document.SaveAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。