class Report
{
private _Application wordApp = null;
private _Document wordDoc = null;
public _Application Application
{
get
{
return wordApp;
}
set
{
wordApp = value;
}
}
public _Document Document
{
get
{
return wordDoc;
}
set
{
wordDoc = value;
}
} //通过模板创建新文档
public void CreateNewDocument(string filePath)
{
killWinWordProcess();
wordApp = new ApplicationClass();
wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
wordApp.Visible = false;
object missing = System.Reflection.Missing.Value;
object templateName = filePath;
wordDoc = wordApp.Documents.Open(ref templateName, 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);
}
我从网上找的一段代码,他说这是他封装好的Report类,我粘上后红色部分提示错误
错误 1 类型“Microsoft.Office.Interop.Word.ApplicationClass”未定义构造函数
错误 2 无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass”。请改用适用的接口。
解决方案 »
- 用C#如何实现短信群发功能
- 在gridview模板中添加了checkbox,通过选中checkbox拿到这一行的值
- 如何在调试时指定虚拟目录?
- 在网页引入母板页以后,在那里添加<link>来引入css样式表~~
- 请教一下母板页标题本地化问题
- 我运行asp.net的ip为:111.11.11.1,我想通过HtmlInputFile在ip为:111.11.11.2的计算机上建文件夹,应该怎么做呢?
- 求助,关于Web.config里的页面权限设置
- 这样可能实现吗?
- 请问Datagrid或webgrid编辑时 能实现离开单元格就保存吗? 不要按钮太麻烦了 可以吗?
- 征集通过发射机制实现跨页面传值的代码
- ASP.NET关于事物处理
- JS调用后台函数的问题
http://kb.cnblogs.com/a/2276651/只需要些很少的代码,Aspose.Words到处都能下载