用asp.net从sql数据库中提取数据,并填充到相应的word模板文件 我现在有一个word模板文件,已经建立好书签,现在想使用asp.net从sql数据库中提取数据,并填充到相应的书签中,生成word文档,由于是第一次使用office 开发,希望可以提供一些源代码。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Object Nothing = System.Reflection.Missing.Value; //取得Word文件保存路径 object filename = Server.MapPath("") +@"\rsc.doc";//@"c:\rsc.doc"; //创建一个名为WordApp的组件对象 Word.Application WordApp = new Word.ApplicationClass();// //打开WordDoc文档 Word.Document WordDoc = WordApp.Documents.Open(ref filename,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); //对标签"adjure_class"进行填充 object bkmA = "adjure_class"; if(WordApp.ActiveDocument.Books.Exists("adjure_class") == true) { WordApp.ActiveDocument.Books.get_Item(ref bkmA).Select(); } WordApp.Selection.TypeText("111");//此处内容可从数据库中取,怎么取的代码就省了吧 filename = Server.MapPath("")+@"\docs\test.doc"; WordDoc.SaveAs(ref filename,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); //关闭WordDoc文档对象 WordDoc.Close(ref Nothing, ref Nothing, ref Nothing); //关闭WordApp组件对象 WordApp.Quit(ref Nothing, ref Nothing, ref Nothing); 做一个在线聊天系统需要多少时间? asp.net 加密技术 关于自定义表格绑定到gridview上的问题..求大虾帮忙 FileUpload控件上传大小问题。 为什么用window.open打开是两个窗口呢? 读取当前页及参数的问题 C#初学者求一些视频教程 如何设置让session保存时间多长 一个免费的WEB打印控件 请问如何实现如下样式的DATAGIRD? 9命!!!!VS2005老是自己删我目录 |M| 现在要做图片报表 各位大哥介绍一下有没有什么好方法,还有你们都是怎么做的 谢谢
object filename = Server.MapPath("") +@"\rsc.doc";
//@"c:\rsc.doc"; //创建一个名为WordApp的组件对象
Word.Application WordApp = new Word.ApplicationClass();// //打开WordDoc文档
Word.Document WordDoc = WordApp.Documents.Open(ref filename,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); //对标签"adjure_class"进行填充
object bkmA = "adjure_class"; if(WordApp.ActiveDocument.Books.Exists("adjure_class") == true)
{
WordApp.ActiveDocument.Books.get_Item(ref bkmA).Select();
}
WordApp.Selection.TypeText("111");//此处内容可从数据库中取,怎么取的代码就省了吧 filename = Server.MapPath("")+@"\docs\test.doc"; WordDoc.SaveAs(ref filename,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); //关闭WordDoc文档对象
WordDoc.Close(ref Nothing, ref Nothing, ref Nothing); //关闭WordApp组件对象
WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);