Application是个Excel的接口,通过ApplicationClass可以实现:
Excel.Application app = new Excel.ApplicationClass();
懂了吗?

解决方案 »

  1.   

    using System ;
    using System.Drawing ;
    using System.Collections ;
    using System.ComponentModel ;
    using System.Windows.Forms ;
    using System.Data ;
    using System.Data.SqlClient ;
    public class Form1 : Form
    {
    private Button button1 ;
    private System.ComponentModel.Container components = null ;
    public Form1 ( )
    {//初始化窗体中的各个组件InitializeComponent ( ) ;
    }
    //清除程序中使用的各个资源
    protected override void Dispose ( bool disposing )
    {
    if ( disposing ){if ( components != null ) {components.Dispose ( ) ;}}base.Dispose( disposing ) ;}
    private void InitializeComponent ( )
    {button1 = new Button ( ) ;SuspendLayout ( ) ;button1.Location = new System.Drawing.Point ( 32 , 72 ) ;button1.Name = "button1" ;button1.Size = new System.Drawing.Size ( 100 , 30 ) ;button1.TabIndex = 0 ;button1.Text = "调用Excel文件!" ;button1.Click += new System.EventHandler ( button1_Click ) ;AutoScaleBaseSize = new System.Drawing.Size ( 5 , 13 ) ;this.ClientSize = new System.Drawing.Size ( 292 , 273 ) ;this.Controls.Add ( button1 ) ;this.Name = "Form1" ;this.Text = "如何用Visual C#调用Excel表格!" ;this.ResumeLayout ( false ) ;}
    static void Main ( ) 
    {
    Application.Run ( new Form1 ( ) ) ;
    }
    private void button1_Click ( object sender , System.EventArgs e )
    {
    Excel.Application excel = new Excel.Application( ) ;
    excel.Application.Workbooks.Add ( true ) ;
    excel.Cells[ 1 , 1 ] = "第一行第一列" ; excel.Cells[ 1 , 2 ] = "第一行第二列" ; excel.Cells[ 2 , 1 ] = "第二行第一列" ; excel.Cells[ 2 , 2 ] = "第二行第二列" ; excel.Cells[ 3 , 1 ] = "第三行第一列" ; excel.Cells[ 3 , 2 ] = "第三行第二列" ; excel.Visible = true ; 
    }}
      

  2.   

    http://www.socent.com/dotnet/message.asp?id=185
    看是否有帮助!
      

  3.   

    在 Excel.Application app = new Excel.ApplicationClass();
    出现 未处理的“System.UnauthorizedAccessException”类型的异常出现在 WindowsApplication1.exe 中。其他信息: 拒绝访问。何解?