在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
阅读: 130 评论: 0 作者: 白连启 发表于 2009-06-06 16:09 原文链接 Word.Application app = new Word.Application();//模板文件 string TemplateFile = @"D:\lin\Invoice.doc"; //生成的具有模板样式的新文件 string FileName = @"D:\lin\" + DateTime.Now.ToString("yyyyMMddHHmmssfffffff") + ".doc"; string Fname = DateTime.Now.ToString("yyyyMMddHHmmssfffffff") + ".doc"; //FileName = Server.MapPath("~/UpLoad/TestWord/" + Fname ); //模板文件拷贝到新文件 File.Copy(TemplateFile, FileName); Word.Document doc = new Word.Document(); object Obj_FileName = FileName; object Visible = false; object ReadOnly = false; object missing = System.Reflection.Missing.Value; //打开文件 doc = app.Documents.Open(ref Obj_FileName, ref missing, ref ReadOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref Visible, ref missing, ref missing, ref missing, ref missing); doc.Activate(); foreach (Word.Bookmark bm in doc.Bookmarks) { if (bm.Name == "BookMark_Date") { bm.Select(); bm.Range.Text = "2008";//ViewState["FK_ProdurcePlanID"].ToString(); } // else if (bm.Name == "class") // { // bm.Select(); // bm.Range.Text = ViewState["_class"].ToString(); // } } object IsSave = true; doc.Close(ref IsSave, ref missing, ref missing); Response.Write("<script language='javascript'>alert('生成word成功!');</script>"); 最新新闻: 编辑推荐:百度域名解析出现问题 网站导航:博客园首页 个人主页 新闻 闪存 小组 博问 社区 知识库 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论