1.asp.net 怎么生成wrod文挡
Microsoft.Office.Interop.Word
用这个类
如果.net里没有这个类,要到微软网站上去下载
object nothing=Missing.Value;
Microsoft.Office.Interop.Word._Application wordapp=new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word._Document worddoc=wordapp.Documents.Add(ref nothing,ref nothing,ref nothing,ref nothing);
wordapp.Selection.TypeText("需在word中写入的文本");
worddoc.SaveAs(ref 这里是你的word文件名,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);
2.请教.net生成word文档的方法
注意引用using Microsoft.Office.Interop.Word;
创建代码如下:
Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.Application();//初始化wordApp组件
Document myWordDoc;//创建文档对象
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);
3.asp.net 生成一定格式的word文档并下载
cs模式。
把word库导入到项目中,然后,在功能页面中创建word对象,操作此对象就可以了。
bs模式。
解决方法有两种
1.先把数据装载到gridview或repeater等中,然后,通过response把数据刷到页面上。
2.把word库导入到项目中,然后,在cs文件中编写相应的word控制代码,类似在cs模式下操作word.
以上只是思路,呵呵。具体的实现代码在网络上有很多。
4.Asp.Net MVC 导出excel 前台和后台代码怎么实现啊
建议使用微软报表,使用RDLC,可以在MVC中生成报表,然后支持导出WORD/EXCEL文件
请参考示例
=========
/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx
数据源可以是对象,实际上我们在某个项目中就是这样导出EXCEL文件的。
转载请注明出处51数据库 » .netmvc生成word