本人现在做一个基于B/S的项目,需要把某张表的部分列导出到Excel中,请问如何实现?

解决方案 »

  1.   

    asp.net里导出excel表方法汇总
    http://www.cnblogs.com/zrlhappy/articles/496033.html
      

  2.   

            Response.Clear();
            Response.Buffer = true;        Response.Charset = "GB2312";
            Response.ContentType = "application/vnd.ms-excel";
            Response.ContentEncoding = Encoding.GetEncoding("gb2312");
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.GetEncoding("gb2312")).ToString());
            this.EnableViewState = false;
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            GridView gv = new GridView();
            gv.DataSource = dt;// 这里是你的数据源 (如:DataTable,DataSet)
            gv.DataBind();
            gv.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();
      

  3.   

    如果是基于B/S的用户需要把某张表的部分列导出到Excel中,则用楼上的方法可以实现;如果你自已用,而表又是Oracle数据库创建的,则可以采用pl/sql的report window在执行完sql结果后,直接导入excel中即可,很方便的。
      

  4.   

    推荐一下 MyXls组件生 下面是一个简单的使用说明。一般的格式都能调节
    http://www.cnblogs.com/Lucky2007/archive/2008/08/13/1154752.html