如题:要使用Excel应该引用什么控件啊?

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=8A4CBF47-B888-4832-3389-ED3A3A3C8AABhttp://dotnet.aspx.cc/ShowDetail.aspx?id=EC5E84EC-68F9-4CD7-9E11-6F5C92027F0B
      

  2.   

    给你个代码
    private void btnexcel_Click(object sender, System.EventArgs e)
    {
    Response.Clear(); 
    Response.Buffer= true; 
    if (Session["Language"]!=null && Session["Language"].ToString()!="EN")
    {
    Response.Charset="GB2312";
    }
    Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); 
    if (Session["Language"]!=null && Session["Language"].ToString()!="EN")
    {
    Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
    }//设置输出流为简体中文
    Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
    application/ms-word || application/ms-txt || application/ms-html || 或其他浏览器可直接支持文档 
     
    this.EnableViewState = false;    
    System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
    System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); 
    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
    this.dgBrowse.RenderControl(oHtmlTextWriter);  
    //dgBrowse为DataGrid控件,也可以是动态生成的HtmlTable
    Response.Write(oStringWriter.ToString());
    Response.End();
    }
    用这种方法可以将DataGrid倒入到Excel,然后打印
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=8A4CBF47-B888-4832-3389-ED3A3A3C8AABhttp://dotnet.aspx.cc/ShowDetail.aspx?id=EC5E84EC-68F9-4CD7-9E11-6F5C92027F0B
      

  4.   

    我的意思是:打开一个Excel文件,按照自己的意愿将数据写入该文件。这样可以对付复杂的报表。
    在应用程序中使用过,效果很好。在Web下该怎么办呢???!!!
      

  5.   

    Excel.Application oExcel;
    Excel.WorkBook oBook;
    Object oMissing=System.Reflection.Missing.Value;
    oExcel=new Excel.Application();
    oBook=oExcel.WorkBooks.Add(oMissing);
    for(int i=1;i<=4;i++)
    {
    oExcel.Cells[i,1]=i.ToString();
    oExcel.Cells[i,2]="'bbb2";
    oExcel.Cells[i,3]="'ccc3";
    oExcel.Cells[i,4]="'ddd4";
    }
    oBook.Saved=true;
    oExcel.UserControl=false;
    string mm=Server.MapPath(".")+"\\aa.xls";
    oExcel.ActiveWorkbook.SaveCopyAs(mm);
    oExcel.Quit();
    Reponse.Redirect("aa.xls");笔记上的,忘了在哪看的了,xls文件也可以不发回给用户,而通过调用sharepoint直接在客户机上运行office程序打开服务器上的xls文件,然后编辑保存打印都可以。