创建代码如下:
Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.Application()//初始化wordApp组件
Object Nothing = System.Reflection.Missing.Value
myWordDoc = myWordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing)
//中间可以向word中插入文字、图片、表格等内容
myWordDoc.SaveAs2(docPath, null, ref Nothing)//保存word文档
//关闭WordDoc文档对象
myWordDoc.Close(ref Nothing, ref Nothing, ref Nothing)
//关闭WordApp组件对象
myWordApp.Quit(ref Nothing, ref Nothing, ref Nothing)
要防止复制,可以使用Microsoft.Office.Interop.Word.Document的Protect方法保护文档中的内容。请参考http://msdn.microsoft.com/ZH-CN/library/microsoft.office.interop.word._document.protect(v=VS.100,d=hv.2).aspx
至于防止查看,基本上是不可能的,至少别人截图你是没有办法的。
兄弟,你要用.net生成啥可能都麻烦一点,但生成word就显得太简单了。因为word就是用html语言写的呀,所以你只管把html当文本流写进一个文件后,直接把这个文件的后缀命为.doc,搞定!
代码自己研究去,要我给你,得浪费我至少十分钟,你得给我50分才行,嘻嘻。