在.NET环境下将报表导出Excel和Word 
http://dotnet.aspx.cc/ShowDetail.aspx?id=6AFBF00B-459D-4642-AD14-8A4765FFAFCC

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=BF0A54F9-C7C7-4200-BD9A-802AC1F5DE50
      

  2.   

    see:
    http://community.csdn.net/Expert/topic/3217/3217552.xml?temp=.4888422
      

  3.   

    谢谢你们对我的问题的回复,但还是没有解决问题,都是VB的,怎么没有用C#实现把DataTable中的数据导出到Word的呢?我这样引用
    Word.ApplicationClass word = new Word.ApplicationClass();
    Word.DocumentClass doc = new Word.DocumentClass();
    Type type = doc.GetType();
    doc = word.Documents.Add(null,null,type,false); //这是我调用的方法
    上句中提示的Add函数是(ref object Template, ref object NewTemplate, ref object DocumnetType, ref object Visible);
    但这样的函数怎么调用啊!
    还有
    Word.Table table; 
    table = doc.Tables.Add(doc.Range0,0), dt.Rows.Count + 1, dt.Columns.Count + 1,null,null); //这是我调用的方法
    上句中的Add函数是(Word.Range Range, int NumRows, int NumColumns, ref object DefaultTableBehavior, ref object AutoFitBehavior);
    这两个函数调用都有问题,郁闷中,请大虾们帮小弟看看.....
      

  4.   

    http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp
      

  5.   

    public void ToExcel(System.Web.UI.WebControls.DataGrid ctl)  
    {HttpContext.Current.Response.Charset ="";
    HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=money.xls");

    HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312"); 
    HttpContext.Current.Response.ContentType ="application/ms-excel";//application/msword
    System.IO.StringWriter  tw = new System.IO.StringWriter() ;
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
    ctl.RenderControl(hw);
    HttpContext.Current.Response.Write(tw);
    }
    这是DATAGRID导向XSL,要导向WORD只要改文件名类型就可以了,上面有备注,别外DATATABLE也是一样的道理