using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
//using Excel;
using Microsoft.Office.Interop;
//using Microsoft.Office.Interop.Excel;
using System.Reflection;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{
Excel.Workbook wb = ThisApplication.Workbooks.Open(
"d:\\data.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
}
}
}
以上是msdn的帮助,我放到VS2005里运行说缺少命名空间,各位高手帮我看看什么问题,谢谢!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
//using Excel;
using Microsoft.Office.Interop;
//using Microsoft.Office.Interop.Excel;
using System.Reflection;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{
Excel.Workbook wb = ThisApplication.Workbooks.Open(
"d:\\data.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
}
}
}
以上是msdn的帮助,我放到VS2005里运行说缺少命名空间,各位高手帮我看看什么问题,谢谢!
解决方案 »
- asp.net用户控件图片路径的小问题
- C#自定义控件效果怎么不能显示出来,如何让它显示在运行结果中
- 正则表达式匹配中间的文字。--急,在线等!!!
- c#用timer控件,每间隔1毫秒执行一次,若程序执行时间超出1毫秒,会有什么结果?
- 如何保存iframe中的页面到服务器端?
- [问题]怎么实现两个dll互相调用,其他方案可以解决也可以
- 求教:c#中同一工程中2个窗体怎样传递信息?
- 高手:怎样通过编程把一个xml文件导入到mdb文件中?急!急!急!急!急!
- 关于嵌入式开发、、、请c#高手多多指教
- List<string> ls=new List<string>大量数量模糊查询效率问题!
- 想请教下关于工厂模式的设计思路。。。
- 给父窗体加了个大的图片后,看不到子窗体显示
分别是:excel、Microsoft.Office.Core、VBIDE
----------------
项目右键->添加引用。
错误 1 “WindowsApplication1.Form1”并不包含“Application”的定义 C:\Users\Peter\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs 25 38 WindowsApplication1
# object MissingValue = Type.Missing;
# Microsoft.Office.Interop.Excel.Application app = new Application();
# Microsoft.Office.Interop.Excel.Workbook wbook = app.Workbooks.Open(@"C:\Documents and Settings\v-changl\My Documents\couse.xlsx", MissingValue,
# MissingValue, MissingValue, MissingValue,
# MissingValue, MissingValue, MissingValue,
# MissingValue, MissingValue, MissingValue,
# MissingValue, MissingValue, MissingValue,
# MissingValue);
"d:\\data.xls", 应该先 new 一下,在open吧!